Pay winner ICYPEES rewards

This commit is contained in:
Jesse C. Fisher 2023-07-25 00:42:17 +00:00
parent e64c03fff2
commit 143e711fdd
3 changed files with 19 additions and 10 deletions

View File

@ -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

View File

@ -14,7 +14,7 @@ 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 !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}`
@ -24,6 +24,7 @@ class Player < ActiveRecord::Base
stp.save
end
end
end
return stp.principal
end

View File

@ -8,7 +8,7 @@ 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 !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}`
@ -18,6 +18,7 @@ class User < ActiveRecord::Base
stp.save
end
end
end
return stp.principal
end