Pay winner ICYPEES rewards
This commit is contained in:
parent
9445656565
commit
48356ecd3b
@ -19,6 +19,13 @@ class Play < ActiveRecord::Base
|
||||
self.game.winner_player_id = self.player.id
|
||||
self.game.status = "Player #{self.player.display_name} wins!"
|
||||
# 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
|
||||
end
|
||||
end
|
||||
|
||||
@ -14,14 +14,15 @@ class Player < ActiveRecord::Base
|
||||
stp = SoftTokenPrincipal.where(soft_token: self.soft_token).first_or_initialize
|
||||
if stp.principal.nil?
|
||||
#TODO use principal
|
||||
`dfx identity use anonymous`
|
||||
if `dfx identity use #{soft_token}; echo $?`.to_i == 255
|
||||
`dfx identity new #{soft_token} --disable-encryption`
|
||||
`dfx identity use #{soft_token}`
|
||||
@principal = `dfx identity get-principal`
|
||||
`dfx identity use anonymous`
|
||||
stp.principal = @principal
|
||||
stp.save
|
||||
if !soft_token.nil?
|
||||
if `dfx identity use #{soft_token}; echo $?`.to_i == 255
|
||||
`dfx identity new #{soft_token} --disable-encryption`
|
||||
`dfx identity use #{soft_token}`
|
||||
@principal = `dfx identity get-principal`
|
||||
`dfx identity use anonymous`
|
||||
stp.principal = @principal
|
||||
stp.save
|
||||
end
|
||||
end
|
||||
end
|
||||
return stp.principal
|
||||
|
||||
@ -8,14 +8,15 @@ class User < ActiveRecord::Base
|
||||
stp = SoftTokenPrincipal.where(soft_token: self.soft_token).first_or_initialize
|
||||
if stp.principal.nil?
|
||||
#TODO use principal
|
||||
`dfx identity use anonymous`
|
||||
if `dfx identity use #{soft_token}; echo $?`.to_i == 255
|
||||
if !soft_token.nil?
|
||||
if `dfx identity use #{soft_token}; echo $?`.to_i == 255
|
||||
`dfx identity new #{soft_token} --disable-encryption`
|
||||
`dfx identity use #{soft_token}`
|
||||
@principal = `dfx identity get-principal`
|
||||
`dfx identity use anonymous`
|
||||
stp.principal = @principal
|
||||
stp.save
|
||||
end
|
||||
end
|
||||
end
|
||||
return stp.principal
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user