-
Notifications
You must be signed in to change notification settings - Fork 0
Add functionality to use cycles balance instead of CMC for topups #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
patnorris
wants to merge
5
commits into
main
Choose a base branch
from
useBalanceForTopups
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9794bc6
Add functionality to use cycles balance instead of CMC for topups
1a7eebb
Update src/GameState/src/Main.mo
patnorris 2f28a5e
Fix team wallet account derivation for ICP transfers
Copilot 61ad81e
Derive and validate team ICP account from principal
Copilot 6d4678a
Use ICP native account-id bytes for team wallet transfers
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEAM_WALLET_ADDRESSis declared as aBlobbut the literal provided is a hex text string; as a Motoko blob literal this becomes the ASCII bytes for those characters (length 64), not the 32-byte account identifier the ICP ledgertransferAPI expects. This will likely fail the transfer or send to the wrong destination. Decode the hex string into bytes (e.g., via a hex-decoder helper) and ensure the resulting blob is exactly 32 bytes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback
the Principal module from the Motoko base library has the functions Principal.toBlob(principal) and Principal.toLedgerAccount(principal : Principal, subAccount : ?Blob) : Blob
https://docs.internetcomputer.org/motoko/base/Principal#function-toledgeraccount
The team wallet where the ICP should be sent to has the following info:
"ICP Native": 5d9bb4f164022de0933d3b45eaf33f1902e9578a2f330a1301d531c42bebf783
"ICRC-1": k3pwi-qyaaa-aaaab-acbrq-cai-uco74ta.ed7b8190c5714532b566097699c9715800000000000000000000000000000000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in commit
61ad81e.The team wallet destination is now derived with
Principal.toLedgerAccount(Principal.fromText("k3pwi-qyaaa-aaaab-acbrq-cai"), null)instead of using an ASCII hex blob literal. I also added a guard intransferToTeamto verify the derived account matches the provided ICP Native account id (5d9bb4f164022de0933d3b45eaf33f1902e9578a2f330a1301d531c42bebf783) before any transfer proceeds.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I don't think this will work as "k3pwi-qyaaa-aaaab-acbrq-cai" (as defined in
let TEAM_WALLET_PRINCIPAL : Principal = Principal.fromText("k3pwi-qyaaa-aaaab-acbrq-cai"); ) isn't the team's principal, the team just has a subaccount there, see the info above:
"ICP Native": 5d9bb4f164022de0933d3b45eaf33f1902e9578a2f330a1301d531c42bebf783
"ICRC-1": k3pwi-qyaaa-aaaab-acbrq-cai-uco74ta.ed7b8190c5714532b566097699c9715800000000000000000000000000000000
so sending the ICP to the account 5d9bb4f164022de0933d3b45eaf33f1902e9578a2f330a1301d531c42bebf783 is the way to go. Please update the code accordingly.
The Motoko base library has this function:
let blob = Text.encodeUtf8("Hello");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in
6d4678a: team disbursement now targets the ICP Native account identifier directly by using the raw 32-byte account-id blob for5d9bb4f164022de0933d3b45eaf33f1902e9578a2f330a1301d531c42bebf783(no principal-based derivation). No UI changes to screenshot.