@clarigen/core 4.1.3 → 4.1.5
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/dist/deployment-BoAUH7JK.mjs +58 -0
- package/dist/deployment-BoAUH7JK.mjs.map +1 -0
- package/dist/deployment-Bv57LEA2.d.cts +2 -1
- package/dist/deployment-DRgKqqdY.cjs +94 -0
- package/dist/deployment-DRgKqqdY.cjs.map +1 -0
- package/dist/deployment-hBXji8Xz.d.mts +2 -1
- package/dist/deployment.cjs +8 -1
- package/dist/deployment.mjs +3 -1
- package/dist/index.cjs +901 -2
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -27
- package/dist/index.d.mts +4 -27
- package/dist/index.mjs +831 -2
- package/dist/index.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/deployment-CGEqh8yH.mjs +0 -1
- package/dist/deployment-DN-sbX_m.cjs +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/deployment.ts
|
|
2
|
+
function flatBatch(batches) {
|
|
3
|
+
const txs = [];
|
|
4
|
+
batches.forEach((batch) => txs.push(...batch.transactions));
|
|
5
|
+
return txs;
|
|
6
|
+
}
|
|
7
|
+
function getContractTxs(batches) {
|
|
8
|
+
return flatBatch(batches).filter(isContractDeploymentTx);
|
|
9
|
+
}
|
|
10
|
+
function getDeploymentContract(contractName, deployment) {
|
|
11
|
+
const txs = flatBatch(deployment.plan.batches);
|
|
12
|
+
for (const tx of txs) {
|
|
13
|
+
if (!isContractDeploymentTx(tx)) continue;
|
|
14
|
+
if ("requirement-publish" in tx) {
|
|
15
|
+
const [_, name] = tx["requirement-publish"]["contract-id"].split(".");
|
|
16
|
+
if (name === contractName) return tx;
|
|
17
|
+
} else if ("emulated-contract-publish" in tx) {
|
|
18
|
+
if (tx["emulated-contract-publish"]["contract-name"] === contractName) return tx;
|
|
19
|
+
} else if ("contract-publish" in tx) {
|
|
20
|
+
if (tx["contract-publish"]["contract-name"] === contractName) return tx;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`Unable to find deployment tx for contract '${contractName}'`);
|
|
24
|
+
}
|
|
25
|
+
function getDeploymentTxPath(tx) {
|
|
26
|
+
if (!isContractDeploymentTx(tx)) throw new Error("Unable to get path for tx type.");
|
|
27
|
+
if ("requirement-publish" in tx) return tx["requirement-publish"].path;
|
|
28
|
+
if ("emulated-contract-publish" in tx) return tx["emulated-contract-publish"].path;
|
|
29
|
+
if ("contract-publish" in tx) return tx["contract-publish"].path;
|
|
30
|
+
throw new Error("Couldnt get path for deployment tx.");
|
|
31
|
+
}
|
|
32
|
+
function getIdentifierForDeploymentTx(tx) {
|
|
33
|
+
if (!isContractDeploymentTx(tx)) throw new Error("Unable to get ID for tx type.");
|
|
34
|
+
if ("requirement-publish" in tx) {
|
|
35
|
+
const spec = tx["requirement-publish"];
|
|
36
|
+
const [_, name] = spec["contract-id"].split(".");
|
|
37
|
+
return `${spec["remap-sender"]}.${name}`;
|
|
38
|
+
}
|
|
39
|
+
if ("emulated-contract-publish" in tx) {
|
|
40
|
+
const contract = tx["emulated-contract-publish"];
|
|
41
|
+
return `${contract["emulated-sender"]}.${contract["contract-name"]}`;
|
|
42
|
+
}
|
|
43
|
+
if ("contract-publish" in tx) {
|
|
44
|
+
const contract = tx["contract-publish"];
|
|
45
|
+
return `${contract["expected-sender"]}.${contract["contract-name"]}`;
|
|
46
|
+
}
|
|
47
|
+
throw new Error("Unable to find ID for contract.");
|
|
48
|
+
}
|
|
49
|
+
function isContractDeploymentTx(tx) {
|
|
50
|
+
if ("contract-call" in tx) return false;
|
|
51
|
+
if ("btc-transfer" in tx) return false;
|
|
52
|
+
if ("emulated-contract-call" in tx) return false;
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { getIdentifierForDeploymentTx as a, getDeploymentTxPath as i, getContractTxs as n, isContractDeploymentTx as o, getDeploymentContract as r, flatBatch as t };
|
|
58
|
+
//# sourceMappingURL=deployment-BoAUH7JK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployment-BoAUH7JK.mjs","names":["txs: T[]","txs: DeploymentTransaction[]"],"sources":["../src/deployment.ts"],"sourcesContent":["export type EmulatedContractPublishTransaction = {\n 'emulated-contract-publish': {\n 'contract-name': string;\n 'emulated-sender': string;\n path: string;\n };\n};\n\nexport type RequirementPublishTransaction = {\n 'requirement-publish': {\n 'contract-id': string;\n 'remap-sender': string;\n 'remap-principals': Record<string, string>;\n path: string;\n };\n};\n\nexport type ContractPublishTransaction = {\n 'contract-publish': {\n 'contract-name': string;\n 'expected-sender': string;\n path: string;\n cost: string;\n };\n};\n\nexport type ContractCallTransaction = {\n 'contract-call': {\n 'contract-id': string;\n 'expected-sender': string;\n parameters: Readonly<string[]>;\n method: string;\n cost: string;\n };\n};\n\nexport type EmulatedContractCallTransaction = {\n 'emulated-contract-call': {\n 'contract-id': string;\n 'emulated-sender': string;\n parameters: Readonly<string[]>;\n method: string;\n };\n};\n\nexport type BtcTransferTransaction = {\n 'btc-transfer': {\n 'expected-sender': string;\n recipient: string;\n 'sats-per-byte': string;\n 'sats-amount': string;\n };\n};\n\n// <clarinet>/components/deployments/src/types.rs\n// <TransactionSpecification>\nexport type DeploymentTransaction =\n | EmulatedContractPublishTransaction\n | RequirementPublishTransaction\n | ContractPublishTransaction\n | EmulatedContractCallTransaction\n | BtcTransferTransaction\n | ContractCallTransaction;\n\nexport type ContractDeploymentTransaction =\n | EmulatedContractPublishTransaction\n | RequirementPublishTransaction\n | ContractPublishTransaction;\n\n// type Batch = Transaction[];\nexport type Batch<T extends DeploymentTransaction> = {\n id: number;\n transactions: Readonly<T[]>;\n};\n\nexport type SimnetAccount = {\n address: string;\n name: string;\n balance: string;\n};\n\nexport interface SimnetAccountDeployer extends SimnetAccount {\n name: 'deployer';\n}\n\nexport type SimnetDeploymentPlan = {\n network: 'simnet';\n genesis: {\n wallets: Readonly<[SimnetAccountDeployer, ...SimnetAccount[]]>;\n contracts: Readonly<string[]>;\n };\n plan: {\n batches: Readonly<\n Batch<\n EmulatedContractPublishTransaction | EmulatedContractCallTransaction\n >[]\n >;\n };\n};\n\nexport type DevnetDeploymentPlan = {\n network: 'devnet';\n plan: {\n batches: Readonly<\n Batch<\n | RequirementPublishTransaction\n | ContractPublishTransaction\n | ContractCallTransaction\n | BtcTransferTransaction\n >[]\n >;\n };\n};\n\nexport type TestnetDeploymentPlan = Omit<DevnetDeploymentPlan, 'network'> & {\n network: 'testnet';\n};\n\nexport type MainnetDeploymentPlan = {\n network: 'mainnet';\n plan: {\n batches: Readonly<\n Batch<\n | ContractPublishTransaction\n | ContractCallTransaction\n | BtcTransferTransaction\n >[]\n >;\n };\n};\n\nexport type DeploymentPlan =\n | SimnetDeploymentPlan\n | DevnetDeploymentPlan\n | TestnetDeploymentPlan\n | MainnetDeploymentPlan;\n\nexport function flatBatch<T extends DeploymentTransaction>(\n batches: Batch<T>[]\n) {\n // const start: T[][] = [];\n const txs: T[] = [];\n // biome-ignore lint/complexity/noForEach: ignored using `--suppress`\n batches.forEach((batch) => txs.push(...batch.transactions));\n return txs;\n}\n\nexport function getContractTxs(\n batches: Batch<DeploymentTransaction>[]\n): ContractDeploymentTransaction[] {\n const txs = flatBatch(batches);\n return txs.filter(isContractDeploymentTx);\n}\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ignored using `--suppress`\nexport function getDeploymentContract(\n contractName: string,\n deployment: DeploymentPlan\n): ContractDeploymentTransaction {\n const txs: DeploymentTransaction[] = flatBatch(\n deployment.plan.batches as Batch<DeploymentTransaction>[]\n );\n for (const tx of txs) {\n if (!isContractDeploymentTx(tx)) continue;\n if ('requirement-publish' in tx) {\n const [_, name] = tx['requirement-publish']['contract-id'].split('.');\n if (name === contractName) {\n return tx;\n }\n } else if ('emulated-contract-publish' in tx) {\n if (tx['emulated-contract-publish']['contract-name'] === contractName) {\n return tx;\n }\n } else if ('contract-publish' in tx) {\n const contract = tx['contract-publish'];\n if (contract['contract-name'] === contractName) {\n return tx;\n }\n }\n }\n throw new Error(\n `Unable to find deployment tx for contract '${contractName}'`\n );\n}\n\nexport function getDeploymentTxPath(tx: ContractDeploymentTransaction): string {\n if (!isContractDeploymentTx(tx)) {\n throw new Error('Unable to get path for tx type.');\n }\n if ('requirement-publish' in tx) {\n return tx['requirement-publish'].path;\n }\n if ('emulated-contract-publish' in tx) {\n const contract = tx['emulated-contract-publish'];\n return contract.path;\n }\n if ('contract-publish' in tx) {\n const contract = tx['contract-publish'];\n return contract.path;\n }\n throw new Error('Couldnt get path for deployment tx.');\n}\n\nexport function getIdentifierForDeploymentTx(\n tx: ContractDeploymentTransaction\n): string {\n if (!isContractDeploymentTx(tx)) {\n throw new Error('Unable to get ID for tx type.');\n }\n if ('requirement-publish' in tx) {\n const spec = tx['requirement-publish'];\n const [_, name] = spec['contract-id'].split('.');\n return `${spec['remap-sender']}.${name}`;\n }\n if ('emulated-contract-publish' in tx) {\n const contract = tx['emulated-contract-publish'];\n return `${contract['emulated-sender']}.${contract['contract-name']}`;\n }\n if ('contract-publish' in tx) {\n const contract = tx['contract-publish'];\n return `${contract['expected-sender']}.${contract['contract-name']}`;\n }\n throw new Error('Unable to find ID for contract.');\n}\n\nexport function isContractDeploymentTx(\n tx: DeploymentTransaction\n): tx is ContractDeploymentTransaction {\n if ('contract-call' in tx) return false;\n if ('btc-transfer' in tx) return false;\n if ('emulated-contract-call' in tx) return false;\n return true;\n}\n"],"mappings":";AAyIA,SAAgB,UACd,SACA;CAEA,MAAMA,MAAW,EAAE;AAEnB,SAAQ,SAAS,UAAU,IAAI,KAAK,GAAG,MAAM,aAAa,CAAC;AAC3D,QAAO;;AAGT,SAAgB,eACd,SACiC;AAEjC,QADY,UAAU,QAAQ,CACnB,OAAO,uBAAuB;;AAI3C,SAAgB,sBACd,cACA,YAC+B;CAC/B,MAAMC,MAA+B,UACnC,WAAW,KAAK,QACjB;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AAO"}
|
|
@@ -94,4 +94,5 @@ declare function getDeploymentTxPath(tx: ContractDeploymentTransaction): string;
|
|
|
94
94
|
declare function getIdentifierForDeploymentTx(tx: ContractDeploymentTransaction): string;
|
|
95
95
|
declare function isContractDeploymentTx(tx: DeploymentTransaction): tx is ContractDeploymentTransaction;
|
|
96
96
|
//#endregion
|
|
97
|
-
export { isContractDeploymentTx as S, flatBatch as _, ContractPublishTransaction as a, getDeploymentTxPath as b, DevnetDeploymentPlan as c, MainnetDeploymentPlan as d, RequirementPublishTransaction as f, TestnetDeploymentPlan as g, SimnetDeploymentPlan as h, ContractDeploymentTransaction as i, EmulatedContractCallTransaction as l, SimnetAccountDeployer as m, BtcTransferTransaction as n, DeploymentPlan as o, SimnetAccount as p, ContractCallTransaction as r, DeploymentTransaction as s, Batch as t, EmulatedContractPublishTransaction as u, getContractTxs as v, getIdentifierForDeploymentTx as x, getDeploymentContract as y };
|
|
97
|
+
export { isContractDeploymentTx as S, flatBatch as _, ContractPublishTransaction as a, getDeploymentTxPath as b, DevnetDeploymentPlan as c, MainnetDeploymentPlan as d, RequirementPublishTransaction as f, TestnetDeploymentPlan as g, SimnetDeploymentPlan as h, ContractDeploymentTransaction as i, EmulatedContractCallTransaction as l, SimnetAccountDeployer as m, BtcTransferTransaction as n, DeploymentPlan as o, SimnetAccount as p, ContractCallTransaction as r, DeploymentTransaction as s, Batch as t, EmulatedContractPublishTransaction as u, getContractTxs as v, getIdentifierForDeploymentTx as x, getDeploymentContract as y };
|
|
98
|
+
//# sourceMappingURL=deployment-Bv57LEA2.d.cts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/deployment.ts
|
|
3
|
+
function flatBatch(batches) {
|
|
4
|
+
const txs = [];
|
|
5
|
+
batches.forEach((batch) => txs.push(...batch.transactions));
|
|
6
|
+
return txs;
|
|
7
|
+
}
|
|
8
|
+
function getContractTxs(batches) {
|
|
9
|
+
return flatBatch(batches).filter(isContractDeploymentTx);
|
|
10
|
+
}
|
|
11
|
+
function getDeploymentContract(contractName, deployment) {
|
|
12
|
+
const txs = flatBatch(deployment.plan.batches);
|
|
13
|
+
for (const tx of txs) {
|
|
14
|
+
if (!isContractDeploymentTx(tx)) continue;
|
|
15
|
+
if ("requirement-publish" in tx) {
|
|
16
|
+
const [_, name] = tx["requirement-publish"]["contract-id"].split(".");
|
|
17
|
+
if (name === contractName) return tx;
|
|
18
|
+
} else if ("emulated-contract-publish" in tx) {
|
|
19
|
+
if (tx["emulated-contract-publish"]["contract-name"] === contractName) return tx;
|
|
20
|
+
} else if ("contract-publish" in tx) {
|
|
21
|
+
if (tx["contract-publish"]["contract-name"] === contractName) return tx;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`Unable to find deployment tx for contract '${contractName}'`);
|
|
25
|
+
}
|
|
26
|
+
function getDeploymentTxPath(tx) {
|
|
27
|
+
if (!isContractDeploymentTx(tx)) throw new Error("Unable to get path for tx type.");
|
|
28
|
+
if ("requirement-publish" in tx) return tx["requirement-publish"].path;
|
|
29
|
+
if ("emulated-contract-publish" in tx) return tx["emulated-contract-publish"].path;
|
|
30
|
+
if ("contract-publish" in tx) return tx["contract-publish"].path;
|
|
31
|
+
throw new Error("Couldnt get path for deployment tx.");
|
|
32
|
+
}
|
|
33
|
+
function getIdentifierForDeploymentTx(tx) {
|
|
34
|
+
if (!isContractDeploymentTx(tx)) throw new Error("Unable to get ID for tx type.");
|
|
35
|
+
if ("requirement-publish" in tx) {
|
|
36
|
+
const spec = tx["requirement-publish"];
|
|
37
|
+
const [_, name] = spec["contract-id"].split(".");
|
|
38
|
+
return `${spec["remap-sender"]}.${name}`;
|
|
39
|
+
}
|
|
40
|
+
if ("emulated-contract-publish" in tx) {
|
|
41
|
+
const contract = tx["emulated-contract-publish"];
|
|
42
|
+
return `${contract["emulated-sender"]}.${contract["contract-name"]}`;
|
|
43
|
+
}
|
|
44
|
+
if ("contract-publish" in tx) {
|
|
45
|
+
const contract = tx["contract-publish"];
|
|
46
|
+
return `${contract["expected-sender"]}.${contract["contract-name"]}`;
|
|
47
|
+
}
|
|
48
|
+
throw new Error("Unable to find ID for contract.");
|
|
49
|
+
}
|
|
50
|
+
function isContractDeploymentTx(tx) {
|
|
51
|
+
if ("contract-call" in tx) return false;
|
|
52
|
+
if ("btc-transfer" in tx) return false;
|
|
53
|
+
if ("emulated-contract-call" in tx) return false;
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
Object.defineProperty(exports, 'flatBatch', {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () {
|
|
61
|
+
return flatBatch;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, 'getContractTxs', {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () {
|
|
67
|
+
return getContractTxs;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, 'getDeploymentContract', {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () {
|
|
73
|
+
return getDeploymentContract;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, 'getDeploymentTxPath', {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return getDeploymentTxPath;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(exports, 'getIdentifierForDeploymentTx', {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () {
|
|
85
|
+
return getIdentifierForDeploymentTx;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, 'isContractDeploymentTx', {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () {
|
|
91
|
+
return isContractDeploymentTx;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=deployment-DRgKqqdY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployment-DRgKqqdY.cjs","names":["txs: T[]","txs: DeploymentTransaction[]"],"sources":["../src/deployment.ts"],"sourcesContent":["export type EmulatedContractPublishTransaction = {\n 'emulated-contract-publish': {\n 'contract-name': string;\n 'emulated-sender': string;\n path: string;\n };\n};\n\nexport type RequirementPublishTransaction = {\n 'requirement-publish': {\n 'contract-id': string;\n 'remap-sender': string;\n 'remap-principals': Record<string, string>;\n path: string;\n };\n};\n\nexport type ContractPublishTransaction = {\n 'contract-publish': {\n 'contract-name': string;\n 'expected-sender': string;\n path: string;\n cost: string;\n };\n};\n\nexport type ContractCallTransaction = {\n 'contract-call': {\n 'contract-id': string;\n 'expected-sender': string;\n parameters: Readonly<string[]>;\n method: string;\n cost: string;\n };\n};\n\nexport type EmulatedContractCallTransaction = {\n 'emulated-contract-call': {\n 'contract-id': string;\n 'emulated-sender': string;\n parameters: Readonly<string[]>;\n method: string;\n };\n};\n\nexport type BtcTransferTransaction = {\n 'btc-transfer': {\n 'expected-sender': string;\n recipient: string;\n 'sats-per-byte': string;\n 'sats-amount': string;\n };\n};\n\n// <clarinet>/components/deployments/src/types.rs\n// <TransactionSpecification>\nexport type DeploymentTransaction =\n | EmulatedContractPublishTransaction\n | RequirementPublishTransaction\n | ContractPublishTransaction\n | EmulatedContractCallTransaction\n | BtcTransferTransaction\n | ContractCallTransaction;\n\nexport type ContractDeploymentTransaction =\n | EmulatedContractPublishTransaction\n | RequirementPublishTransaction\n | ContractPublishTransaction;\n\n// type Batch = Transaction[];\nexport type Batch<T extends DeploymentTransaction> = {\n id: number;\n transactions: Readonly<T[]>;\n};\n\nexport type SimnetAccount = {\n address: string;\n name: string;\n balance: string;\n};\n\nexport interface SimnetAccountDeployer extends SimnetAccount {\n name: 'deployer';\n}\n\nexport type SimnetDeploymentPlan = {\n network: 'simnet';\n genesis: {\n wallets: Readonly<[SimnetAccountDeployer, ...SimnetAccount[]]>;\n contracts: Readonly<string[]>;\n };\n plan: {\n batches: Readonly<\n Batch<\n EmulatedContractPublishTransaction | EmulatedContractCallTransaction\n >[]\n >;\n };\n};\n\nexport type DevnetDeploymentPlan = {\n network: 'devnet';\n plan: {\n batches: Readonly<\n Batch<\n | RequirementPublishTransaction\n | ContractPublishTransaction\n | ContractCallTransaction\n | BtcTransferTransaction\n >[]\n >;\n };\n};\n\nexport type TestnetDeploymentPlan = Omit<DevnetDeploymentPlan, 'network'> & {\n network: 'testnet';\n};\n\nexport type MainnetDeploymentPlan = {\n network: 'mainnet';\n plan: {\n batches: Readonly<\n Batch<\n | ContractPublishTransaction\n | ContractCallTransaction\n | BtcTransferTransaction\n >[]\n >;\n };\n};\n\nexport type DeploymentPlan =\n | SimnetDeploymentPlan\n | DevnetDeploymentPlan\n | TestnetDeploymentPlan\n | MainnetDeploymentPlan;\n\nexport function flatBatch<T extends DeploymentTransaction>(\n batches: Batch<T>[]\n) {\n // const start: T[][] = [];\n const txs: T[] = [];\n // biome-ignore lint/complexity/noForEach: ignored using `--suppress`\n batches.forEach((batch) => txs.push(...batch.transactions));\n return txs;\n}\n\nexport function getContractTxs(\n batches: Batch<DeploymentTransaction>[]\n): ContractDeploymentTransaction[] {\n const txs = flatBatch(batches);\n return txs.filter(isContractDeploymentTx);\n}\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ignored using `--suppress`\nexport function getDeploymentContract(\n contractName: string,\n deployment: DeploymentPlan\n): ContractDeploymentTransaction {\n const txs: DeploymentTransaction[] = flatBatch(\n deployment.plan.batches as Batch<DeploymentTransaction>[]\n );\n for (const tx of txs) {\n if (!isContractDeploymentTx(tx)) continue;\n if ('requirement-publish' in tx) {\n const [_, name] = tx['requirement-publish']['contract-id'].split('.');\n if (name === contractName) {\n return tx;\n }\n } else if ('emulated-contract-publish' in tx) {\n if (tx['emulated-contract-publish']['contract-name'] === contractName) {\n return tx;\n }\n } else if ('contract-publish' in tx) {\n const contract = tx['contract-publish'];\n if (contract['contract-name'] === contractName) {\n return tx;\n }\n }\n }\n throw new Error(\n `Unable to find deployment tx for contract '${contractName}'`\n );\n}\n\nexport function getDeploymentTxPath(tx: ContractDeploymentTransaction): string {\n if (!isContractDeploymentTx(tx)) {\n throw new Error('Unable to get path for tx type.');\n }\n if ('requirement-publish' in tx) {\n return tx['requirement-publish'].path;\n }\n if ('emulated-contract-publish' in tx) {\n const contract = tx['emulated-contract-publish'];\n return contract.path;\n }\n if ('contract-publish' in tx) {\n const contract = tx['contract-publish'];\n return contract.path;\n }\n throw new Error('Couldnt get path for deployment tx.');\n}\n\nexport function getIdentifierForDeploymentTx(\n tx: ContractDeploymentTransaction\n): string {\n if (!isContractDeploymentTx(tx)) {\n throw new Error('Unable to get ID for tx type.');\n }\n if ('requirement-publish' in tx) {\n const spec = tx['requirement-publish'];\n const [_, name] = spec['contract-id'].split('.');\n return `${spec['remap-sender']}.${name}`;\n }\n if ('emulated-contract-publish' in tx) {\n const contract = tx['emulated-contract-publish'];\n return `${contract['emulated-sender']}.${contract['contract-name']}`;\n }\n if ('contract-publish' in tx) {\n const contract = tx['contract-publish'];\n return `${contract['expected-sender']}.${contract['contract-name']}`;\n }\n throw new Error('Unable to find ID for contract.');\n}\n\nexport function isContractDeploymentTx(\n tx: DeploymentTransaction\n): tx is ContractDeploymentTransaction {\n if ('contract-call' in tx) return false;\n if ('btc-transfer' in tx) return false;\n if ('emulated-contract-call' in tx) return false;\n return true;\n}\n"],"mappings":";;AAyIA,SAAgB,UACd,SACA;CAEA,MAAMA,MAAW,EAAE;AAEnB,SAAQ,SAAS,UAAU,IAAI,KAAK,GAAG,MAAM,aAAa,CAAC;AAC3D,QAAO;;AAGT,SAAgB,eACd,SACiC;AAEjC,QADY,UAAU,QAAQ,CACnB,OAAO,uBAAuB;;AAI3C,SAAgB,sBACd,cACA,YAC+B;CAC/B,MAAMC,MAA+B,UACnC,WAAW,KAAK,QACjB;AACD,MAAK,MAAM,MAAM,KAAK;AACpB,MAAI,CAAC,uBAAuB,GAAG,CAAE;AACjC,MAAI,y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94
|
declare function getIdentifierForDeploymentTx(tx: ContractDeploymentTransaction): string;
|
|
95
95
|
declare function isContractDeploymentTx(tx: DeploymentTransaction): tx is ContractDeploymentTransaction;
|
|
96
96
|
//#endregion
|
|
97
|
-
export { isContractDeploymentTx as S, flatBatch as _, ContractPublishTransaction as a, getDeploymentTxPath as b, DevnetDeploymentPlan as c, MainnetDeploymentPlan as d, RequirementPublishTransaction as f, TestnetDeploymentPlan as g, SimnetDeploymentPlan as h, ContractDeploymentTransaction as i, EmulatedContractCallTransaction as l, SimnetAccountDeployer as m, BtcTransferTransaction as n, DeploymentPlan as o, SimnetAccount as p, ContractCallTransaction as r, DeploymentTransaction as s, Batch as t, EmulatedContractPublishTransaction as u, getContractTxs as v, getIdentifierForDeploymentTx as x, getDeploymentContract as y };
|
|
97
|
+
export { isContractDeploymentTx as S, flatBatch as _, ContractPublishTransaction as a, getDeploymentTxPath as b, DevnetDeploymentPlan as c, MainnetDeploymentPlan as d, RequirementPublishTransaction as f, TestnetDeploymentPlan as g, SimnetDeploymentPlan as h, ContractDeploymentTransaction as i, EmulatedContractCallTransaction as l, SimnetAccountDeployer as m, BtcTransferTransaction as n, DeploymentPlan as o, SimnetAccount as p, ContractCallTransaction as r, DeploymentTransaction as s, Batch as t, EmulatedContractPublishTransaction as u, getContractTxs as v, getIdentifierForDeploymentTx as x, getDeploymentContract as y };
|
|
98
|
+
//# sourceMappingURL=deployment-hBXji8Xz.d.mts.map
|
package/dist/deployment.cjs
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_deployment = require('./deployment-DRgKqqdY.cjs');
|
|
2
|
+
|
|
3
|
+
exports.flatBatch = require_deployment.flatBatch;
|
|
4
|
+
exports.getContractTxs = require_deployment.getContractTxs;
|
|
5
|
+
exports.getDeploymentContract = require_deployment.getDeploymentContract;
|
|
6
|
+
exports.getDeploymentTxPath = require_deployment.getDeploymentTxPath;
|
|
7
|
+
exports.getIdentifierForDeploymentTx = require_deployment.getIdentifierForDeploymentTx;
|
|
8
|
+
exports.isContractDeploymentTx = require_deployment.isContractDeploymentTx;
|
package/dist/deployment.mjs
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import { a as getIdentifierForDeploymentTx, i as getDeploymentTxPath, n as getContractTxs, o as isContractDeploymentTx, r as getDeploymentContract, t as flatBatch } from "./deployment-BoAUH7JK.mjs";
|
|
2
|
+
|
|
3
|
+
export { flatBatch, getContractTxs, getDeploymentContract, getDeploymentTxPath, getIdentifierForDeploymentTx, isContractDeploymentTx };
|