@kaspacom/kcc20-tx-builder 0.8.0-fee.3 → 0.8.0-fee.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/RELEASING.md +3 -2
- package/dist/cjs/engine.js +12 -1
- package/dist/cjs/engine.js.map +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +12 -1
- package/dist/engine.js.map +1 -1
- package/docs/COMPATIBILITY.json +1 -1
- package/docs/escrow-fees.md +3 -1
- package/package.json +1 -1
- package/src/engine.ts +15 -1
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAyErD,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE;QACf,mBAAmB,CAAC,IAAI,EAAE;YAAE,SAAS,EAAE,MAAM,EAAE,CAAA;SAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;KACtE,CAAC;IACF,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,GAAG,CAAC;IAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yBAAyB,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE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,MAAM,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAC5C,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,6BAA6B,GACrC,sBAAsB,CA23axB"}
|
package/dist/engine.js
CHANGED
|
@@ -380,6 +380,7 @@ export function createKcc20PsktBuilderEngine(options) {
|
|
|
380
380
|
const principalSompi = parseU64(params.principalSompi, "fee account principal");
|
|
381
381
|
const network = request.network || env.KASPA_NETWORK || "testnet-10";
|
|
382
382
|
const walletAddress = requireKaspaAddress(request.owner?.walletAddress);
|
|
383
|
+
assertFeeAccountSchnorrWalletOwner(walletAddress, owner);
|
|
383
384
|
const priorityFee = parseU64(env.KCC20_FEE_ACCOUNT_PRIORITY_FEE_SOMPI || DEFAULT_PRIORITY_FEE.toString(), "priorityFee");
|
|
384
385
|
const artifactKey = "KCC20FeeEscrowV1.placeholder.json";
|
|
385
386
|
const supplied = options.artifacts?.[artifactKey] ?? await options.artifactProvider?.(artifactKey);
|
|
@@ -497,6 +498,7 @@ export function createKcc20PsktBuilderEngine(options) {
|
|
|
497
498
|
}
|
|
498
499
|
const network = request.network || env.KASPA_NETWORK || "testnet-10";
|
|
499
500
|
const walletAddress = requireKaspaAddress(request.owner?.walletAddress);
|
|
501
|
+
assertFeeAccountSchnorrWalletOwner(walletAddress, owner);
|
|
500
502
|
const accountAddress = requireKaspaAddress(indexed.address);
|
|
501
503
|
const priorityFee = parseU64(env.KCC20_FEE_ACCOUNT_PRIORITY_FEE_SOMPI || DEFAULT_PRIORITY_FEE.toString(), "priorityFee");
|
|
502
504
|
const computeBudget = parsePositiveNumber(env.KCC20_FEE_ACCOUNT_COMPUTE_BUDGET || 500, "computeBudget");
|
|
@@ -542,7 +544,7 @@ export function createKcc20PsktBuilderEngine(options) {
|
|
|
542
544
|
tokenId, accountId, marketId, policyId,
|
|
543
545
|
});
|
|
544
546
|
assertScriptAddress(kw, plan.currentRedeemScript, accountAddress, network, "unbound fee account address");
|
|
545
|
-
const fundingEntry = selectFundingEntry(walletUtxos.entries, priorityFee + 10000n, [], params.fundingOutpoint);
|
|
547
|
+
const fundingEntry = selectFundingEntry(walletUtxos.entries, priorityFee + 10000n, [accountEntry.outpoint], params.fundingOutpoint);
|
|
546
548
|
const fundingAmount = utxoAmountSompi(fundingEntry);
|
|
547
549
|
if (fundingAmount <= priorityFee + 10000n)
|
|
548
550
|
throw new Error("fee account binding funding change is too small");
|
|
@@ -565,6 +567,7 @@ export function createKcc20PsktBuilderEngine(options) {
|
|
|
565
567
|
});
|
|
566
568
|
setVersionOneInputMassFields(unsignedTx, computeBudget);
|
|
567
569
|
unsignedTx.inputs[1].computeBudget = 30;
|
|
570
|
+
assertUniqueTransactionInputOutpoints(unsignedTx, "fee account binding");
|
|
568
571
|
const scripts = [{
|
|
569
572
|
inputIndex: 0,
|
|
570
573
|
scriptHex: bytesToHex(plan.currentRedeemScript),
|
|
@@ -9338,6 +9341,14 @@ export function createKcc20PsktBuilderEngine(options) {
|
|
|
9338
9341
|
throw new Error("owner.walletAddress must be a Kaspa address");
|
|
9339
9342
|
return address;
|
|
9340
9343
|
}
|
|
9344
|
+
function assertFeeAccountSchnorrWalletOwner(walletAddress, owner) {
|
|
9345
|
+
const script = String(kaspaWasm.payToAddressScript(walletAddress).script)
|
|
9346
|
+
.toLowerCase();
|
|
9347
|
+
const publicKey = /^20([0-9a-f]{64})ac$/.exec(script)?.[1];
|
|
9348
|
+
if (!publicKey || publicKey !== owner) {
|
|
9349
|
+
throw new Error("fee account owner must match the connected Schnorr wallet address");
|
|
9350
|
+
}
|
|
9351
|
+
}
|
|
9341
9352
|
return {
|
|
9342
9353
|
build: buildInProcessPskt,
|
|
9343
9354
|
buildInProcessPskt,
|