Skip to content

Commit

Permalink
fix: little decimal bug
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurvinci committed Apr 25, 2024
1 parent d7eb900 commit a132597
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/StringManifest/MethodsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function addressFrom(globalAddress: string): string {
*/
export function lockFee(account: string, amount?: Decimal): string {
let to_lock = amount ? amount : 20;
return callMethod("lock_fee", account, [`Decimal("${to_lock}")`]);
return callMethod("lock_fee", account, [decimalToArg(to_lock)]);
}

/**
Expand All @@ -42,11 +42,11 @@ export function fungibleBucket(
${addressFrom(account)}
"withdraw"
${addressFrom(bucket.address)}
Decimal("${bucket.amount}");
${decimalToArg(bucket.amount)};
TAKE_FROM_WORKTOP
${addressFrom(bucket.address)}
Decimal("${bucket.amount}")
${decimalToArg(bucket.amount)}
Bucket("${bucketName}");`;
}

Expand Down Expand Up @@ -124,6 +124,10 @@ export function array<T>(type_name: string, content: T[]): string {
return vec_string;
}

export function decimalToArg(decimal: Decimal): string {
return `Decimal("${decimal}")`
}

/**
* Returns a manifest instruction to create a proof of an amount of fungibles.
* @param account Account from which to create the proof.
Expand All @@ -137,7 +141,7 @@ export function createProofOfAmount(
): string {
return callMethod("create_proof_of_amount", account, [
addressFrom(resourceAddress),
`Decimal(${amount})`,
decimalToArg(amount),
]);
}

Expand Down

0 comments on commit a132597

Please sign in to comment.