Skip to content

Commit

Permalink
feature(mobile): Recursively rebuild stonfi swap payload (#802)
Browse files Browse the repository at this point in the history
  • Loading branch information
voloshinskii authored Apr 17, 2024
1 parent 693f81d commit 1a98b87
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/@core-js/src/service/contractService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import nacl from 'tweetnacl';
export enum OpCodes {
JETTON_TRANSFER = 0xf8a7ea5,
NFT_TRANSFER = 0x5fcc3d14,
STONFI_SWAP = 0x25938561,
}

export enum WalletVersion {
Expand Down
21 changes: 20 additions & 1 deletion packages/@core-js/src/service/transactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ export class TransactionService {
let builder = beginCell();

switch (opCode) {
case OpCodes.STONFI_SWAP:
builder = builder
.storeUint(OpCodes.STONFI_SWAP, 32)
.storeAddress(slice.loadAddress())
.storeCoins(slice.loadCoins())
.storeAddress(slice.loadAddress());

if (slice.loadBoolean()) {
slice.loadAddress();
}

return builder
.storeBit(1)
.storeAddress(Address.parse(customExcessesAccount))
.endCell();
case OpCodes.NFT_TRANSFER:
builder = builder
.storeUint(OpCodes.NFT_TRANSFER, 32)
Expand All @@ -130,7 +145,11 @@ export class TransactionService {
slice.loadMaybeAddress();

while (slice.remainingRefs) {
builder = builder.storeRef(slice.loadRef());
const forwardCell = slice.loadRef();
// recursively rebuild forward payloads
builder = builder.storeRef(
this.rebuildBodyWithCustomExcessesAccount(forwardCell, customExcessesAccount),
);
}

return builder
Expand Down

0 comments on commit 1a98b87

Please sign in to comment.