Pay winner ICYPEES rewards
This commit is contained in:
parent
ba2c87fc5c
commit
4b79baf695
@ -19,6 +19,13 @@ class Play < ActiveRecord::Base
|
|||||||
self.game.winner_player_id = self.player.id
|
self.game.winner_player_id = self.player.id
|
||||||
self.game.status = "Player #{self.player.display_name} wins!"
|
self.game.status = "Player #{self.player.display_name} wins!"
|
||||||
# TODO Pay out crypto
|
# TODO Pay out crypto
|
||||||
|
# pay icypees rewards
|
||||||
|
if !self.player.principal.nil?
|
||||||
|
`dfx identity use 13rewards`
|
||||||
|
player_wallet_balance = `dfx canister --network ic call es3he-kyaaa-aaaah-abzna-cai transfer '(principal "#{self.player.principal.strip}", 100000000:nat)'`
|
||||||
|
`dfx identity use anonymous`
|
||||||
|
end
|
||||||
|
|
||||||
self.game.save
|
self.game.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -14,14 +14,15 @@ class Player < ActiveRecord::Base
|
|||||||
stp = SoftTokenPrincipal.where(soft_token: self.soft_token).first_or_initialize
|
stp = SoftTokenPrincipal.where(soft_token: self.soft_token).first_or_initialize
|
||||||
if stp.principal.nil?
|
if stp.principal.nil?
|
||||||
#TODO use principal
|
#TODO use principal
|
||||||
`dfx identity use anonymous`
|
if !soft_token.nil?
|
||||||
if `dfx identity use #{soft_token}; echo $?`.to_i == 255
|
if `dfx identity use #{soft_token}; echo $?`.to_i == 255
|
||||||
`dfx identity new #{soft_token} --disable-encryption`
|
`dfx identity new #{soft_token} --disable-encryption`
|
||||||
`dfx identity use #{soft_token}`
|
`dfx identity use #{soft_token}`
|
||||||
@principal = `dfx identity get-principal`
|
@principal = `dfx identity get-principal`
|
||||||
`dfx identity use anonymous`
|
`dfx identity use anonymous`
|
||||||
stp.principal = @principal
|
stp.principal = @principal
|
||||||
stp.save
|
stp.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return stp.principal
|
return stp.principal
|
||||||
|
|||||||
@ -8,14 +8,15 @@ class User < ActiveRecord::Base
|
|||||||
stp = SoftTokenPrincipal.where(soft_token: self.soft_token).first_or_initialize
|
stp = SoftTokenPrincipal.where(soft_token: self.soft_token).first_or_initialize
|
||||||
if stp.principal.nil?
|
if stp.principal.nil?
|
||||||
#TODO use principal
|
#TODO use principal
|
||||||
`dfx identity use anonymous`
|
if !soft_token.nil?
|
||||||
if `dfx identity use #{soft_token}; echo $?`.to_i == 255
|
if `dfx identity use #{soft_token}; echo $?`.to_i == 255
|
||||||
`dfx identity new #{soft_token} --disable-encryption`
|
`dfx identity new #{soft_token} --disable-encryption`
|
||||||
`dfx identity use #{soft_token}`
|
`dfx identity use #{soft_token}`
|
||||||
@principal = `dfx identity get-principal`
|
@principal = `dfx identity get-principal`
|
||||||
`dfx identity use anonymous`
|
`dfx identity use anonymous`
|
||||||
stp.principal = @principal
|
stp.principal = @principal
|
||||||
stp.save
|
stp.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return stp.principal
|
return stp.principal
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user