@kaspacom/kcc20-tx-builder 0.4.0 → 0.6.0
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 +12 -1
- package/README.md +2 -2
- package/RELEASING.md +19 -14
- package/artifacts/ArgentKCC20.reference.json +12428 -0
- package/artifacts/ArgentKCC20Wrapper.placeholder.json +12455 -0
- package/artifacts/KCC20.placeholder.json +1447 -1973
- package/artifacts/KCC20FeeTicket.placeholder.json +816 -1447
- package/artifacts/KCC20Orderbook.placeholder.json +1 -2
- package/artifacts/KCC20SnapshotBootstrap.placeholder.json +101 -100
- package/artifacts/KCC20SnapshotController.placeholder.json +101 -100
- package/artifacts/KCC20Vesting.placeholder.json +427 -429
- package/artifacts/KCC20Wrapper.placeholder.json +733 -734
- package/artifacts/kcc20-snapshot-bootstrap/KCC20SnapshotBootstrap.placeholder.json +101 -100
- package/artifacts/kcc20-snapshot-controller/KCC20SnapshotController.placeholder.json +101 -100
- package/artifacts/snapshot-standards.lock.json +6 -3
- package/artifacts/token-profiles.json +109 -0
- package/artifacts/token-profiles.sha256 +1 -0
- package/dist/action-source-resolver.d.ts.map +1 -1
- package/dist/action-source-resolver.js +11 -2
- package/dist/action-source-resolver.js.map +1 -1
- package/dist/artifacts.d.ts +10 -10
- package/dist/artifacts.d.ts.map +1 -1
- package/dist/artifacts.js +10 -10
- package/dist/artifacts.js.map +1 -1
- package/dist/cjs/action-source-resolver.js +11 -2
- package/dist/cjs/action-source-resolver.js.map +1 -1
- package/dist/cjs/artifacts.d.ts +10 -10
- package/dist/cjs/artifacts.js +10 -10
- package/dist/cjs/artifacts.js.map +1 -1
- package/dist/cjs/engine.d.ts +10 -0
- package/dist/cjs/engine.js +124 -77
- package/dist/cjs/engine.js.map +1 -1
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/profile-transfer.d.ts +60 -0
- package/dist/cjs/profile-transfer.js +248 -0
- package/dist/cjs/profile-transfer.js.map +1 -0
- package/dist/cjs/snapshot-operation.d.ts +0 -1
- package/dist/cjs/snapshot-operation.js +1 -1126
- package/dist/cjs/snapshot-operation.js.map +1 -1
- package/dist/cjs/snapshot-signerless-transactions.d.ts +1 -1
- package/dist/cjs/snapshot-signerless-transactions.js +3 -6
- package/dist/cjs/snapshot-signerless-transactions.js.map +1 -1
- package/dist/cjs/snapshot-signerless.js +5 -3
- package/dist/cjs/snapshot-signerless.js.map +1 -1
- package/dist/cjs/snapshot-verification.d.ts +1 -1
- package/dist/cjs/snapshot-verification.js +16 -12
- package/dist/cjs/snapshot-verification.js.map +1 -1
- package/dist/cjs/token-authorization.d.ts +42 -0
- package/dist/cjs/token-authorization.js +93 -0
- package/dist/cjs/token-authorization.js.map +1 -0
- package/dist/cjs/token-profiles.d.ts +82 -0
- package/dist/cjs/token-profiles.generated.d.ts +3 -0
- package/dist/cjs/token-profiles.generated.js +114 -0
- package/dist/cjs/token-profiles.generated.js.map +1 -0
- package/dist/cjs/token-profiles.js +257 -0
- package/dist/cjs/token-profiles.js.map +1 -0
- package/dist/cjs/transfer-payload.d.ts +9 -0
- package/dist/cjs/transfer-payload.js +37 -0
- package/dist/cjs/transfer-payload.js.map +1 -0
- package/dist/cjs/wrapper-operation.d.ts +1 -0
- package/dist/cjs/wrapper-operation.js +1 -0
- package/dist/cjs/wrapper-operation.js.map +1 -1
- package/dist/engine.d.ts +10 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +125 -78
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/profile-transfer.d.ts +61 -0
- package/dist/profile-transfer.d.ts.map +1 -0
- package/dist/profile-transfer.js +245 -0
- package/dist/profile-transfer.js.map +1 -0
- package/dist/snapshot-operation.d.ts +0 -1
- package/dist/snapshot-operation.d.ts.map +1 -1
- package/dist/snapshot-operation.js +0 -1125
- package/dist/snapshot-operation.js.map +1 -1
- package/dist/snapshot-signerless-transactions.d.ts +1 -1
- package/dist/snapshot-signerless-transactions.d.ts.map +1 -1
- package/dist/snapshot-signerless-transactions.js +3 -6
- package/dist/snapshot-signerless-transactions.js.map +1 -1
- package/dist/snapshot-signerless.d.ts.map +1 -1
- package/dist/snapshot-signerless.js +5 -3
- package/dist/snapshot-signerless.js.map +1 -1
- package/dist/snapshot-verification.d.ts +1 -1
- package/dist/snapshot-verification.d.ts.map +1 -1
- package/dist/snapshot-verification.js +16 -12
- package/dist/snapshot-verification.js.map +1 -1
- package/dist/token-authorization.d.ts +43 -0
- package/dist/token-authorization.d.ts.map +1 -0
- package/dist/token-authorization.js +88 -0
- package/dist/token-authorization.js.map +1 -0
- package/dist/token-profiles.d.ts +83 -0
- package/dist/token-profiles.d.ts.map +1 -0
- package/dist/token-profiles.generated.d.ts +4 -0
- package/dist/token-profiles.generated.d.ts.map +1 -0
- package/dist/token-profiles.generated.js +111 -0
- package/dist/token-profiles.generated.js.map +1 -0
- package/dist/token-profiles.js +245 -0
- package/dist/token-profiles.js.map +1 -0
- package/dist/transfer-payload.d.ts +10 -0
- package/dist/transfer-payload.d.ts.map +1 -0
- package/dist/transfer-payload.js +34 -0
- package/dist/transfer-payload.js.map +1 -0
- package/dist/wrapper-operation.d.ts +1 -0
- package/dist/wrapper-operation.d.ts.map +1 -1
- package/dist/wrapper-operation.js +1 -0
- package/dist/wrapper-operation.js.map +1 -1
- package/docs/API.md +1 -1
- package/docs/COMPATIBILITY.json +24 -33
- package/docs/INTEGRATION.md +2 -2
- package/docs/LAST_CALL.md +50 -0
- package/examples/README.md +5 -2
- package/examples/backend/cli.ts +2 -1
- package/examples/frontend/main.ts +2 -1
- package/examples/shared/build.ts +3 -0
- package/examples/shared/offline-profile.ts +27 -0
- package/examples/shared/recipe-fixtures.ts +3 -2
- package/examples/test/browser.ts +2 -2
- package/examples/test/build.test.ts +21 -8
- package/examples/test/sources.test.ts +3 -2
- package/package.json +2 -2
- package/src/action-source-resolver.ts +22 -4
- package/src/artifacts.ts +12 -10
- package/src/engine.ts +208 -105
- package/src/index.ts +7 -0
- package/src/profile-transfer.ts +425 -0
- package/src/snapshot-operation.ts +59 -1731
- package/src/snapshot-signerless-transactions.ts +8 -17
- package/src/snapshot-signerless.ts +5 -3
- package/src/snapshot-verification.ts +17 -13
- package/src/token-authorization.ts +135 -0
- package/src/token-profiles.generated.ts +112 -0
- package/src/token-profiles.ts +456 -0
- package/src/transfer-payload.ts +45 -0
- package/src/wrapper-operation.ts +2 -0
|
@@ -61,10 +61,7 @@ export function buildSnapshotKcc20DeploymentPayload({
|
|
|
61
61
|
if (normalizedProtocolFeeBps > 10_000n) {
|
|
62
62
|
throw new Error("snapshot token protocol fee bps exceeds 10000");
|
|
63
63
|
}
|
|
64
|
-
const normalizedMigrationId = hex32(
|
|
65
|
-
migrationId,
|
|
66
|
-
"snapshot migration id",
|
|
67
|
-
);
|
|
64
|
+
const normalizedMigrationId = hex32(migrationId, "snapshot migration id");
|
|
68
65
|
const normalizedManifestCommitment = hex32(
|
|
69
66
|
manifestCommitment,
|
|
70
67
|
"snapshot manifest commitment",
|
|
@@ -132,11 +129,7 @@ export function buildSnapshotKcc20DeploymentPayload({
|
|
|
132
129
|
claimArg("displayScale", "u64", normalizedDisplayScale.toString()),
|
|
133
130
|
claimArg("mintPriceSompi", "u64", "0"),
|
|
134
131
|
claimArg("treasury", "byte[32]", normalizedTreasury),
|
|
135
|
-
claimArg(
|
|
136
|
-
"protocolFeeRecipient",
|
|
137
|
-
"byte[32]",
|
|
138
|
-
normalizedFeeRecipient,
|
|
139
|
-
),
|
|
132
|
+
claimArg("protocolFeeRecipient", "byte[32]", normalizedFeeRecipient),
|
|
140
133
|
claimArg("protocolFeeBps", "u64", normalizedProtocolFeeBps.toString()),
|
|
141
134
|
claimArg("ticker", "string", normalizedTicker),
|
|
142
135
|
claimArg("name", "string", normalizedName),
|
|
@@ -274,7 +267,7 @@ export function buildSnapshotStartUnsignedTransaction(
|
|
|
274
267
|
fundingInput,
|
|
275
268
|
changeAddress,
|
|
276
269
|
feeSompi,
|
|
277
|
-
payload =
|
|
270
|
+
payload = new Uint8Array() as Uint8Array<ArrayBufferLike>,
|
|
278
271
|
},
|
|
279
272
|
) {
|
|
280
273
|
requirePlan(plan, "snapshot-start-plan");
|
|
@@ -780,9 +773,7 @@ function fixedText32(value, label) {
|
|
|
780
773
|
}
|
|
781
774
|
|
|
782
775
|
function bytesHex(value) {
|
|
783
|
-
return [...value]
|
|
784
|
-
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
785
|
-
.join("");
|
|
776
|
+
return [...value].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
786
777
|
}
|
|
787
778
|
|
|
788
779
|
function transactionOf(kw, inputs, outputs, lockTime, payload) {
|
|
@@ -968,10 +959,10 @@ function setP2shSignatureScript(
|
|
|
968
959
|
revealScript,
|
|
969
960
|
prefix,
|
|
970
961
|
) {
|
|
971
|
-
transaction.inputs[inputIndex].signatureScript =
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
962
|
+
transaction.inputs[inputIndex].signatureScript = kw.ScriptBuilder.fromScript(
|
|
963
|
+
revealScript,
|
|
964
|
+
{ flags: { covenantsEnabled: true } },
|
|
965
|
+
).encodePayToScriptHashSignatureScript(prefix);
|
|
975
966
|
}
|
|
976
967
|
|
|
977
968
|
function unsignedEnvelope(kw, transaction, intent, signInputs) {
|
|
@@ -363,7 +363,9 @@ export function buildSnapshotStartSignatureScripts(
|
|
|
363
363
|
const reserves = plan.reserves.map(normalizeKcc20State);
|
|
364
364
|
const kcc20Template = templateParts(kcc20Artifact);
|
|
365
365
|
const controllerTemplate = templateParts(controllerArtifact);
|
|
366
|
-
const bootstrapBuilder = new kw.ScriptBuilder(
|
|
366
|
+
const bootstrapBuilder = new kw.ScriptBuilder({
|
|
367
|
+
flags: { covenantsEnabled: true },
|
|
368
|
+
});
|
|
367
369
|
for (const field of encodeControllerStateRecordArrays(controllers))
|
|
368
370
|
bootstrapBuilder.addData(field);
|
|
369
371
|
for (const field of encodeKcc20StateRecordArrays(reserves))
|
|
@@ -374,7 +376,7 @@ export function buildSnapshotStartSignatureScripts(
|
|
|
374
376
|
bootstrapBuilder.addData(controllerTemplate.suffix);
|
|
375
377
|
bootstrapBuilder.addData(dispatchTagFor(bootstrapArtifact, "start"));
|
|
376
378
|
const controllerSignatureScripts = controllers.map((state, index) => {
|
|
377
|
-
const builder = new kw.ScriptBuilder();
|
|
379
|
+
const builder = new kw.ScriptBuilder({ flags: { covenantsEnabled: true } });
|
|
378
380
|
addControllerState(builder, state);
|
|
379
381
|
builder.addI64(BigInt(bootstrapInputIndex));
|
|
380
382
|
builder.addI64(BigInt(index));
|
|
@@ -591,7 +593,7 @@ export function buildClaimSignatureScripts(
|
|
|
591
593
|
requireControllerArtifact(controllerArtifact);
|
|
592
594
|
requireKcc20Artifact(kcc20Artifact);
|
|
593
595
|
requireOwnerWitness(claim.ownerScheme, claim.ownerWitness);
|
|
594
|
-
const builder = new kw.ScriptBuilder();
|
|
596
|
+
const builder = new kw.ScriptBuilder({ flags: { covenantsEnabled: true } });
|
|
595
597
|
builder.addI64(BigInt(claim.globalIndex));
|
|
596
598
|
builder.addI64(BigInt(claim.shardLeafIndex));
|
|
597
599
|
addByte(builder, claim.ownerScheme);
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { prepareSnapshotDeployment, type SnapshotArtifacts, type SnapshotDeploymentDefinition } from './snapshot-deployment.js';
|
|
2
|
-
import { bytesToHex } from './encoding.js';
|
|
3
2
|
import * as tx from './snapshot-signerless-transactions.js';
|
|
4
3
|
|
|
5
|
-
export function snapshotStartPayload(definition: SnapshotDeploymentDefinition, prepared: ReturnType<typeof prepareSnapshotDeployment>):
|
|
4
|
+
export function snapshotStartPayload(definition: SnapshotDeploymentDefinition, prepared: ReturnType<typeof prepareSnapshotDeployment>): Uint8Array {
|
|
6
5
|
const plan = prepared.plan;
|
|
7
6
|
if (prepared.stage !== 'snapshot-start') throw new Error('snapshot start plan required');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
return tx.buildSnapshotKcc20DeploymentPayload({
|
|
8
|
+
creator: definition.creator,
|
|
9
|
+
ticker: definition.ticker,
|
|
10
|
+
name: definition.ticker,
|
|
11
|
+
displayScale: definition.displayScale,
|
|
12
|
+
totalSupply: definition.totalSupply,
|
|
13
|
+
holderExtensionCommitment: prepared.holderExtensionCommitment,
|
|
14
|
+
migrationId: definition.migrationId,
|
|
15
|
+
manifestCommitment: definition.manifestCommitment,
|
|
16
|
+
reserves: plan.reserves,
|
|
17
|
+
treasury: definition.creator,
|
|
18
|
+
protocolFeeRecipient: definition.creator,
|
|
19
|
+
protocolFeeBps: 0,
|
|
20
|
+
});
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
/** Reconstruct the whole transaction from approved definition and pinned artifacts. */
|
|
@@ -59,7 +62,8 @@ export function verifySnapshotDeploymentTransaction(kw: any, args: {
|
|
|
59
62
|
throw new Error('snapshot bootstrap input differs from approved genesis');
|
|
60
63
|
}
|
|
61
64
|
expected = tx.buildSnapshotStartUnsignedTransaction(kw, {
|
|
62
|
-
...common,
|
|
65
|
+
...common,
|
|
66
|
+
payload: snapshotStartPayload(args.definition, prepared),
|
|
63
67
|
bootstrapInput,
|
|
64
68
|
controllerInputs: plan.controllers.map((controller: any, index: number) => {
|
|
65
69
|
const actual = input(index + 1, tx.buildSnapshotControllerScriptForState(args.artifacts.controllerArtifact, controller.stateBefore));
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { blake3 } from "@noble/hashes/blake3";
|
|
2
|
+
import { requireTokenCapability, type TokenProfile } from "./token-profiles.js";
|
|
3
|
+
|
|
4
|
+
export interface TokenSigningCapabilities {
|
|
5
|
+
schnorr: boolean;
|
|
6
|
+
ecdsa: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type TokenWitnessArgument =
|
|
9
|
+
| { type: "data"; hex: string }
|
|
10
|
+
| { type: "signature"; prefixHex: string };
|
|
11
|
+
export interface TokenAuthorityInput {
|
|
12
|
+
index: number;
|
|
13
|
+
scriptPublicKeyHex: string;
|
|
14
|
+
covenantId?: string;
|
|
15
|
+
}
|
|
16
|
+
const hex = (v: Uint8Array) =>
|
|
17
|
+
Array.from(v, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
18
|
+
const bytes = (v: string, size: number, label: string) => {
|
|
19
|
+
if (!new RegExp(`^[0-9a-f]{${size * 2}}$`, "i").test(v))
|
|
20
|
+
throw new Error(`invalid ${label}`);
|
|
21
|
+
return Uint8Array.from(v.match(/../g)!, (b) => parseInt(b, 16));
|
|
22
|
+
};
|
|
23
|
+
export function tokenPublicKeyHash(publicKey: Uint8Array): Uint8Array {
|
|
24
|
+
if (![32, 33].includes(publicKey.length))
|
|
25
|
+
throw new Error("invalid token public key length");
|
|
26
|
+
return blake3(publicKey);
|
|
27
|
+
}
|
|
28
|
+
/** Authority inputs must come from the authenticated transaction UTXOs, never an uploaded artifact. */
|
|
29
|
+
export function planTokenOwnerWitness(input: {
|
|
30
|
+
profile: TokenProfile;
|
|
31
|
+
owner: string;
|
|
32
|
+
ownerScheme: number;
|
|
33
|
+
publicKey?: string;
|
|
34
|
+
capabilities: TokenSigningCapabilities;
|
|
35
|
+
authorityInputIndex?: number;
|
|
36
|
+
authorityInputs?: readonly TokenAuthorityInput[];
|
|
37
|
+
role: "leader" | "delegator";
|
|
38
|
+
}): {
|
|
39
|
+
argument: TokenWitnessArgument;
|
|
40
|
+
signatureAlgorithm?: "schnorr" | "ecdsa";
|
|
41
|
+
authorityInputIndex?: number;
|
|
42
|
+
} {
|
|
43
|
+
const { profile, ownerScheme } = input;
|
|
44
|
+
requireTokenCapability(profile, "transfer");
|
|
45
|
+
bytes(input.owner, 32, "token owner");
|
|
46
|
+
if (!profile.ownerSchemes.includes(ownerScheme))
|
|
47
|
+
throw new Error("token profile does not support this owner scheme");
|
|
48
|
+
const prefix = input.role === "leader" ? "00" : "";
|
|
49
|
+
if (ownerScheme <= 2) {
|
|
50
|
+
const algorithm = ownerScheme === 2 ? "ecdsa" : "schnorr";
|
|
51
|
+
if (!input.capabilities[algorithm])
|
|
52
|
+
throw new Error(`wallet does not support ${algorithm} token signatures`);
|
|
53
|
+
const key = bytes(
|
|
54
|
+
input.publicKey ?? "",
|
|
55
|
+
ownerScheme === 2 ? 33 : 32,
|
|
56
|
+
"wallet public key",
|
|
57
|
+
);
|
|
58
|
+
if (ownerScheme === 2 && key[0] !== 2 && key[0] !== 3)
|
|
59
|
+
throw new Error("ECDSA key must be compressed");
|
|
60
|
+
const expected =
|
|
61
|
+
ownerScheme === 0 ? hex(key) : hex(tokenPublicKeyHash(key));
|
|
62
|
+
if (expected !== input.owner.toLowerCase())
|
|
63
|
+
throw new Error("wallet public key does not own the token output");
|
|
64
|
+
return {
|
|
65
|
+
argument: {
|
|
66
|
+
type: "signature",
|
|
67
|
+
prefixHex: prefix + (ownerScheme === 0 ? "" : hex(key)),
|
|
68
|
+
},
|
|
69
|
+
signatureAlgorithm: algorithm,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const index = input.authorityInputIndex;
|
|
73
|
+
if (!Number.isSafeInteger(index) || index! < 0 || index! > 255)
|
|
74
|
+
throw new Error("explicit authority input index is required");
|
|
75
|
+
const matches = (input.authorityInputs ?? []).filter(
|
|
76
|
+
(a) => a.index === index,
|
|
77
|
+
);
|
|
78
|
+
if (matches.length !== 1)
|
|
79
|
+
throw new Error("authority input is missing or ambiguous");
|
|
80
|
+
const authority = matches[0];
|
|
81
|
+
if (
|
|
82
|
+
ownerScheme === 3 &&
|
|
83
|
+
authority.scriptPublicKeyHex.toLowerCase() !==
|
|
84
|
+
`aa20${input.owner.toLowerCase()}87`
|
|
85
|
+
)
|
|
86
|
+
throw new Error("authority input does not match token P2SH owner");
|
|
87
|
+
if (
|
|
88
|
+
ownerScheme === 4 &&
|
|
89
|
+
authority.covenantId?.toLowerCase() !== input.owner.toLowerCase()
|
|
90
|
+
)
|
|
91
|
+
throw new Error("authority input does not match token covenant owner");
|
|
92
|
+
return {
|
|
93
|
+
argument: {
|
|
94
|
+
type: "data",
|
|
95
|
+
hex:
|
|
96
|
+
prefix +
|
|
97
|
+
(ownerScheme === 3 ? index!.toString(16).padStart(2, "0") : ""),
|
|
98
|
+
},
|
|
99
|
+
authorityInputIndex: index,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Borrowing is an explicit mode. This function never converts an ordinary send into a borrow. */
|
|
103
|
+
export function buildTokenBorrowWitness(input: {
|
|
104
|
+
profile: TokenProfile;
|
|
105
|
+
borrowScheme: number;
|
|
106
|
+
currentGuard: string;
|
|
107
|
+
signature?: string;
|
|
108
|
+
nextGuard?: string;
|
|
109
|
+
oneTimePublicKey?: string;
|
|
110
|
+
}): Uint8Array {
|
|
111
|
+
requireTokenCapability(input.profile, "borrow");
|
|
112
|
+
const current = bytes(input.currentGuard, 32, "borrow guard");
|
|
113
|
+
if (input.borrowScheme === 1) {
|
|
114
|
+
if (
|
|
115
|
+
input.signature !== undefined ||
|
|
116
|
+
input.nextGuard !== undefined ||
|
|
117
|
+
input.oneTimePublicKey !== undefined
|
|
118
|
+
)
|
|
119
|
+
throw new Error("threshold borrowing requires an empty authorization");
|
|
120
|
+
return Uint8Array.of(1);
|
|
121
|
+
}
|
|
122
|
+
const sig = bytes(input.signature ?? "", 65, "borrow signature");
|
|
123
|
+
if (input.borrowScheme === 2) {
|
|
124
|
+
if (input.nextGuard !== undefined || input.oneTimePublicKey !== undefined)
|
|
125
|
+
throw new Error("Schnorr borrowing does not rotate its guard");
|
|
126
|
+
return Uint8Array.from([1, ...sig]);
|
|
127
|
+
}
|
|
128
|
+
if (input.borrowScheme !== 3)
|
|
129
|
+
throw new Error("unsupported or disabled borrow scheme");
|
|
130
|
+
const guard = bytes(input.nextGuard ?? "", 32, "next borrow guard");
|
|
131
|
+
const key = bytes(input.oneTimePublicKey ?? "", 32, "one-time public key");
|
|
132
|
+
if (hex(blake3(Uint8Array.from([...guard, ...key]))) !== hex(current))
|
|
133
|
+
throw new Error("hash-chain link does not match current guard");
|
|
134
|
+
return Uint8Array.from([1, ...guard, ...key, ...sig]);
|
|
135
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Generated by scripts/sync-reviewed-artifacts.mjs. Do not edit.
|
|
2
|
+
import type { TokenProfileRegistry } from "./token-profiles.js";
|
|
3
|
+
export const BUNDLED_TOKEN_PROFILE_DIGEST = "dd4880c1b89564d250fefb09949c07235e23d7fcbca0ff3f061396b515455b01";
|
|
4
|
+
export const BUNDLED_TOKEN_PROFILES: TokenProfileRegistry = {
|
|
5
|
+
"schema": "kcc20-token-profiles/v2",
|
|
6
|
+
"standardRevision": "3fbec524abfbc20e87652eb938db218f8c17db17",
|
|
7
|
+
"profiles": [
|
|
8
|
+
{
|
|
9
|
+
"id": "kaspacom-kcc20-last-call-v1",
|
|
10
|
+
"artifactKey": "KCC20.placeholder.json",
|
|
11
|
+
"artifactSha256": "a45d06e8351421dac1ef73f3595c6f34068e4fa1e13d3f8fa1c88be518c6e56f",
|
|
12
|
+
"artifactCanonicalSha256": "2c299e2d354fd3d0e61b0987778d18bd0e5f17ccfdee614eb98a48fcf5779a8b",
|
|
13
|
+
"scriptSha256": "dd9cb334cd9e9220b15644782f271ef3ecdba34fd0762010e3d6bc18176837ae",
|
|
14
|
+
"scriptLength": 25377,
|
|
15
|
+
"templateHash": "5d6cacdf57c734536fcb8a9c833f0318671226727ec77c503a98fc5be59f9e29",
|
|
16
|
+
"stateLayout": {
|
|
17
|
+
"start": 1,
|
|
18
|
+
"len": 112
|
|
19
|
+
},
|
|
20
|
+
"standardRevision": "3fbec524abfbc20e87652eb938db218f8c17db17",
|
|
21
|
+
"transferEntrypoint": "transfer",
|
|
22
|
+
"delegatorEntrypoint": "transfer_delegator",
|
|
23
|
+
"transferTag": "79c71c23",
|
|
24
|
+
"delegatorTag": "fd3ef14a",
|
|
25
|
+
"ownerSchemes": [
|
|
26
|
+
0,
|
|
27
|
+
1,
|
|
28
|
+
2,
|
|
29
|
+
3,
|
|
30
|
+
4
|
|
31
|
+
],
|
|
32
|
+
"maxTokenInputs": 8,
|
|
33
|
+
"maxTokenOutputs": 8,
|
|
34
|
+
"operations": [
|
|
35
|
+
"transfer",
|
|
36
|
+
"borrow",
|
|
37
|
+
"mint",
|
|
38
|
+
"burn",
|
|
39
|
+
"wrap",
|
|
40
|
+
"unwrap",
|
|
41
|
+
"trade"
|
|
42
|
+
],
|
|
43
|
+
"fungibility": "single-holder-class",
|
|
44
|
+
"nativeExtensions": true,
|
|
45
|
+
"wrapper": {
|
|
46
|
+
"fingerprint": "0634803d0cb750fb555f5eccbd57d18d9638736b675caab290e46a8acdbb25dd",
|
|
47
|
+
"artifactKey": "KCC20Wrapper.placeholder.json",
|
|
48
|
+
"artifactSha256": "2461e39a285d1f135f4891659cb78b3b6e5d2b28b32e153b61e2e336eab02115",
|
|
49
|
+
"artifactCanonicalSha256": "0eba9f91c89c180f3683e61e11bae9ab9b8cfe8674e98e58e9f2b2b1e920be83",
|
|
50
|
+
"scriptSha256": "23cbd5473860cab4e63890d24ae1bd6732fce5beaa34f594dad01e845e3e9b9f",
|
|
51
|
+
"scriptLength": 3895,
|
|
52
|
+
"stateLayout": {
|
|
53
|
+
"start": 1,
|
|
54
|
+
"len": 44
|
|
55
|
+
},
|
|
56
|
+
"templateHash": "c4e08636c63cbd33e3a0703167a480cc4af3a42444f24c4d526df84104280515",
|
|
57
|
+
"tokenTemplateHash": "5d6cacdf57c734536fcb8a9c833f0318671226727ec77c503a98fc5be59f9e29"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "argent-reference-kcc20-v1",
|
|
62
|
+
"artifactKey": "ArgentKCC20.reference.json",
|
|
63
|
+
"transferEntrypoint": "transfer",
|
|
64
|
+
"delegatorEntrypoint": "transfer_delegator",
|
|
65
|
+
"transferTag": "79c71c23",
|
|
66
|
+
"delegatorTag": "fd3ef14a",
|
|
67
|
+
"ownerSchemes": [
|
|
68
|
+
0,
|
|
69
|
+
1,
|
|
70
|
+
2,
|
|
71
|
+
3,
|
|
72
|
+
4
|
|
73
|
+
],
|
|
74
|
+
"maxTokenInputs": 3,
|
|
75
|
+
"maxTokenOutputs": 3,
|
|
76
|
+
"operations": [
|
|
77
|
+
"transfer",
|
|
78
|
+
"borrow",
|
|
79
|
+
"wrap",
|
|
80
|
+
"unwrap",
|
|
81
|
+
"trade"
|
|
82
|
+
],
|
|
83
|
+
"fungibility": "single-holder-class",
|
|
84
|
+
"displayDecimals": 0,
|
|
85
|
+
"artifactSha256": "eb95459fdcfd63c3736be623984f49529899fb03288f1363e340eb3acf74e513",
|
|
86
|
+
"artifactCanonicalSha256": "dab8e196dc29fccc10b51a50a48cf45d9253de63822c7fcd703702cc70673ab9",
|
|
87
|
+
"scriptSha256": "f3d52b46bc8994a0b564557ea474cd4f79d2c054dcddbc2b017aaad3b306b1e8",
|
|
88
|
+
"scriptLength": 4031,
|
|
89
|
+
"templateHash": "734850b0af0aeef49f009167bf9ddd238fd8c5cdbe214234f97181ac6f5cc498",
|
|
90
|
+
"stateLayout": {
|
|
91
|
+
"start": 34,
|
|
92
|
+
"len": 112
|
|
93
|
+
},
|
|
94
|
+
"standardRevision": "3fbec524abfbc20e87652eb938db218f8c17db17",
|
|
95
|
+
"nativeExtensions": false,
|
|
96
|
+
"wrapper": {
|
|
97
|
+
"fingerprint": "455772a93ec788b755a832655eee96d14050c3dfb2263a4fd8d7dd19705632d4",
|
|
98
|
+
"artifactKey": "ArgentKCC20Wrapper.placeholder.json",
|
|
99
|
+
"artifactSha256": "fc3b21bdd90cef56d18f4eb2e05b2b0938cb631cfda2a247c99caeec4e505235",
|
|
100
|
+
"artifactCanonicalSha256": "0e1c99e12b53299305317ac663d69e7190e38a8fd33b53355fff86f847c74480",
|
|
101
|
+
"scriptSha256": "4ae0e302539180a2586b22dfe2aeb579bd867e680d3fddf712b724b7d3d41fa8",
|
|
102
|
+
"scriptLength": 3965,
|
|
103
|
+
"stateLayout": {
|
|
104
|
+
"start": 1,
|
|
105
|
+
"len": 44
|
|
106
|
+
},
|
|
107
|
+
"templateHash": "1fbe92003266693d2a527d1fc8a4cb1397773f2922702b921aec723a541a6420",
|
|
108
|
+
"tokenTemplateHash": "734850b0af0aeef49f009167bf9ddd238fd8c5cdbe214234f97181ac6f5cc498"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
};
|