tenzro-sdk 0.3.0 → 0.4.1
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/README.md +10 -0
- package/dist/a2a-extension.d.ts +42 -0
- package/dist/a2a-extension.d.ts.map +1 -0
- package/dist/a2a-extension.js +55 -0
- package/dist/a2a-extension.js.map +1 -0
- package/dist/api-key.d.ts +128 -0
- package/dist/api-key.d.ts.map +1 -0
- package/dist/api-key.js +94 -0
- package/dist/api-key.js.map +1 -0
- package/dist/axelar.d.ts +54 -0
- package/dist/axelar.d.ts.map +1 -0
- package/dist/axelar.js +30 -0
- package/dist/axelar.js.map +1 -0
- package/dist/babylon.d.ts +46 -0
- package/dist/babylon.d.ts.map +1 -0
- package/dist/babylon.js +37 -0
- package/dist/babylon.js.map +1 -0
- package/dist/caip-helpers.d.ts +64 -0
- package/dist/caip-helpers.d.ts.map +1 -0
- package/dist/caip-helpers.js +100 -0
- package/dist/caip-helpers.js.map +1 -0
- package/dist/caip.d.ts +43 -0
- package/dist/caip.d.ts.map +1 -0
- package/dist/caip.js +29 -0
- package/dist/caip.js.map +1 -0
- package/dist/canton.d.ts +16 -18
- package/dist/canton.d.ts.map +1 -1
- package/dist/canton.js +16 -18
- package/dist/canton.js.map +1 -1
- package/dist/capital.d.ts +167 -0
- package/dist/capital.d.ts.map +1 -0
- package/dist/capital.js +117 -0
- package/dist/capital.js.map +1 -0
- package/dist/client.d.ts +27 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +37 -0
- package/dist/client.js.map +1 -1
- package/dist/did-tenzro-helpers.d.ts +36 -0
- package/dist/did-tenzro-helpers.d.ts.map +1 -0
- package/dist/did-tenzro-helpers.js +77 -0
- package/dist/did-tenzro-helpers.js.map +1 -0
- package/dist/hyperlane.d.ts +47 -0
- package/dist/hyperlane.d.ts.map +1 -0
- package/dist/hyperlane.js +27 -0
- package/dist/hyperlane.js.map +1 -0
- package/dist/index.d.ts +27 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -2
- package/dist/index.js.map +1 -1
- package/dist/permit2.d.ts +49 -0
- package/dist/permit2.d.ts.map +1 -0
- package/dist/permit2.js +30 -0
- package/dist/permit2.js.map +1 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +16 -0
- package/dist/rpc.js.map +1 -1
- package/dist/secure-mint.d.ts +39 -0
- package/dist/secure-mint.d.ts.map +1 -0
- package/dist/secure-mint.js +44 -0
- package/dist/secure-mint.js.map +1 -0
- package/dist/training.d.ts +61 -0
- package/dist/training.d.ts.map +1 -1
- package/dist/training.js +76 -1
- package/dist/training.js.map +1 -1
- package/dist/types.d.ts +93 -27
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/workflow.d.ts +98 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +131 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pure helpers around the submitted `tenzro` CASA namespace
|
|
4
|
+
* (`ChainAgnostic/namespaces#184`). These functions reference the
|
|
5
|
+
* frozen spec values and are safe to use without an RPC round-trip:
|
|
6
|
+
* parsing, validation, and constants.
|
|
7
|
+
*
|
|
8
|
+
* For runtime-derived identifiers (the CAIP-2 reference, which depends
|
|
9
|
+
* on the genesis block hash for the network the wallet is connected
|
|
10
|
+
* to), use the `CaipClient` from `./caip.ts`.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.TENZRO_SLIP44_COIN_INDEX = exports.TENZRO_CAIP2_NAMESPACE = void 0;
|
|
14
|
+
exports.isTenzroCaip2 = isTenzroCaip2;
|
|
15
|
+
exports.buildTenzroCaip2 = buildTenzroCaip2;
|
|
16
|
+
exports.parseTenzroCaip2 = parseTenzroCaip2;
|
|
17
|
+
exports.isTenzroCaip10 = isTenzroCaip10;
|
|
18
|
+
exports.parseTenzroCaip19 = parseTenzroCaip19;
|
|
19
|
+
/** CAIP-2 namespace string for Tenzro. */
|
|
20
|
+
exports.TENZRO_CAIP2_NAMESPACE = 'tenzro';
|
|
21
|
+
/**
|
|
22
|
+
* SLIP-44 coin index for native TNZO. Pre-registered until
|
|
23
|
+
* `satoshilabs/slips#2015` merges; the string form `"tenzro"` is also
|
|
24
|
+
* accepted on input by the node-side helpers.
|
|
25
|
+
*/
|
|
26
|
+
exports.TENZRO_SLIP44_COIN_INDEX = 1_414_421_071;
|
|
27
|
+
/**
|
|
28
|
+
* Validate that a string looks like a Tenzro CAIP-2 chain id —
|
|
29
|
+
* `tenzro:<32-hex chars>`. Does NOT verify the reference is the live
|
|
30
|
+
* network's genesis hash; for that, compare against `CaipClient.caip2()`.
|
|
31
|
+
*/
|
|
32
|
+
function isTenzroCaip2(chainId) {
|
|
33
|
+
return /^tenzro:[0-9a-f]{32}$/.test(chainId);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build a Tenzro CAIP-2 chain id from a 16-byte reference (the first
|
|
37
|
+
* 16 bytes of the genesis block hash). Pass either a `Uint8Array` of
|
|
38
|
+
* length 16, a 32-char lowercase hex string, or a `0x`-prefixed
|
|
39
|
+
* 34-char hex string. Throws if the reference is the wrong length.
|
|
40
|
+
*/
|
|
41
|
+
function buildTenzroCaip2(reference) {
|
|
42
|
+
let hex;
|
|
43
|
+
if (typeof reference === 'string') {
|
|
44
|
+
hex = reference.toLowerCase().startsWith('0x')
|
|
45
|
+
? reference.slice(2).toLowerCase()
|
|
46
|
+
: reference.toLowerCase();
|
|
47
|
+
if (hex.length !== 32) {
|
|
48
|
+
throw new Error(`CAIP-2 reference must be exactly 32 hex chars (16 bytes); got ${hex.length}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
if (reference.length !== 16) {
|
|
53
|
+
throw new Error(`CAIP-2 reference must be exactly 16 bytes; got ${reference.length}`);
|
|
54
|
+
}
|
|
55
|
+
hex = Array.from(reference, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
56
|
+
}
|
|
57
|
+
return `${exports.TENZRO_CAIP2_NAMESPACE}:${hex}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parse a Tenzro CAIP-2 chain id into `{ namespace, reference }`.
|
|
61
|
+
* Returns `null` if the input doesn't match the Tenzro shape.
|
|
62
|
+
*/
|
|
63
|
+
function parseTenzroCaip2(chainId) {
|
|
64
|
+
if (!isTenzroCaip2(chainId))
|
|
65
|
+
return null;
|
|
66
|
+
return { namespace: 'tenzro', reference: chainId.slice('tenzro:'.length) };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Validate a Tenzro CAIP-10 account id: `tenzro:<32-hex>:<address>`.
|
|
70
|
+
* Tenzro addresses are 32 bytes (64-hex), but base58btc inputs are
|
|
71
|
+
* accepted on the node side and normalized, so this validator only
|
|
72
|
+
* checks the structural shape of the canonical hex form.
|
|
73
|
+
*/
|
|
74
|
+
function isTenzroCaip10(accountId) {
|
|
75
|
+
return /^tenzro:[0-9a-f]{32}:[0-9a-f]{64}$/.test(accountId);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validate a Tenzro CAIP-19 asset id and return its parts. Returns
|
|
79
|
+
* `null` if the input doesn't match the Tenzro shape.
|
|
80
|
+
*
|
|
81
|
+
* Forms:
|
|
82
|
+
* - `tenzro:<chainRef>/slip44:1414421071` (native TNZO)
|
|
83
|
+
* - `tenzro:<chainRef>/token:<64-hex>`
|
|
84
|
+
* - `tenzro:<chainRef>/nft:<64-hex>/<tokenId>`
|
|
85
|
+
*/
|
|
86
|
+
function parseTenzroCaip19(assetId) {
|
|
87
|
+
const m = assetId.match(/^tenzro:([0-9a-f]{32})\/(slip44|token|nft):([0-9a-zA-Z]+)(?:\/([0-9a-zA-Z]+))?$/);
|
|
88
|
+
if (!m)
|
|
89
|
+
return null;
|
|
90
|
+
const [, chainRef, ns, ref, tokenId] = m;
|
|
91
|
+
if (!chainRef || !ns || !ref)
|
|
92
|
+
return null;
|
|
93
|
+
return {
|
|
94
|
+
chainRef,
|
|
95
|
+
namespace: ns,
|
|
96
|
+
reference: ref,
|
|
97
|
+
...(tokenId !== undefined ? { tokenId } : {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=caip-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caip-helpers.js","sourceRoot":"","sources":["../src/caip-helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAoBH,sCAEC;AAQD,4CAoBC;AAMD,4CAKC;AAQD,wCAEC;AAWD,8CAkBC;AAlGD,0CAA0C;AAC7B,QAAA,sBAAsB,GAAG,QAAQ,CAAC;AAE/C;;;;GAIG;AACU,QAAA,wBAAwB,GAAG,aAAa,CAAC;AAKtD;;;;GAIG;AACH,SAAgB,aAAa,CAAC,OAAe;IAC3C,OAAO,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,SAA8B;IAC7D,IAAI,GAAW,CAAC;IAChB,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YAC5C,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;YAClC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QAC5B,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,iEAAiE,GAAG,CAAC,MAAM,EAAE,CAC9E,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,CAAC;QACN,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YAC5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AAE,CAAC;KAC9C,CAAC;AACJ,CAAC"}
|
package/dist/caip.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { RpcClient } from './rpc';
|
|
2
|
+
export interface Caip2Info {
|
|
3
|
+
chain_id: string;
|
|
4
|
+
namespace: string;
|
|
5
|
+
reference: string;
|
|
6
|
+
evm_chain_id: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Caip10Info {
|
|
9
|
+
account_id: string;
|
|
10
|
+
chain_id: string;
|
|
11
|
+
address: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Caip19Request {
|
|
14
|
+
/** One of `"slip44"`, `"token"`, `"nft"`. */
|
|
15
|
+
kind: 'slip44' | 'token' | 'nft' | string;
|
|
16
|
+
token_id?: string;
|
|
17
|
+
collection_id?: string;
|
|
18
|
+
nft_token_id?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface Caip19Info {
|
|
21
|
+
asset_id: string;
|
|
22
|
+
chain_id: string;
|
|
23
|
+
asset_namespace: string;
|
|
24
|
+
asset_reference: string;
|
|
25
|
+
token_id?: string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Chain-agnostic discovery client per the submitted `tenzro` CASA
|
|
29
|
+
* namespace (`ChainAgnostic/namespaces#184`).
|
|
30
|
+
*
|
|
31
|
+
* - CAIP-2 chain id: `tenzro:<lowercase hex of first 16 bytes of
|
|
32
|
+
* genesis block hash>`. EVM `evm_chain_id` sidecar is included.
|
|
33
|
+
* - CAIP-10: accepts hex or base58btc, normalises to canonical 64-hex.
|
|
34
|
+
* - CAIP-19: `slip44` (SLIP-44 coin index 1414421071), `token`, `nft`.
|
|
35
|
+
*/
|
|
36
|
+
export declare class CaipClient {
|
|
37
|
+
private readonly rpc;
|
|
38
|
+
constructor(rpc: RpcClient);
|
|
39
|
+
caip2(): Promise<Caip2Info>;
|
|
40
|
+
caip10(address: string): Promise<Caip10Info>;
|
|
41
|
+
caip19(params: Caip19Request): Promise<Caip19Info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@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CaipClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Chain-agnostic discovery client per the submitted `tenzro` CASA
|
|
6
|
+
* namespace (`ChainAgnostic/namespaces#184`).
|
|
7
|
+
*
|
|
8
|
+
* - CAIP-2 chain id: `tenzro:<lowercase hex of first 16 bytes of
|
|
9
|
+
* genesis block hash>`. EVM `evm_chain_id` sidecar is included.
|
|
10
|
+
* - CAIP-10: accepts hex or base58btc, normalises to canonical 64-hex.
|
|
11
|
+
* - CAIP-19: `slip44` (SLIP-44 coin index 1414421071), `token`, `nft`.
|
|
12
|
+
*/
|
|
13
|
+
class CaipClient {
|
|
14
|
+
rpc;
|
|
15
|
+
constructor(rpc) {
|
|
16
|
+
this.rpc = rpc;
|
|
17
|
+
}
|
|
18
|
+
async caip2() {
|
|
19
|
+
return this.rpc.call('tenzro_caip2', []);
|
|
20
|
+
}
|
|
21
|
+
async caip10(address) {
|
|
22
|
+
return this.rpc.call('tenzro_caip10', [{ address }]);
|
|
23
|
+
}
|
|
24
|
+
async caip19(params) {
|
|
25
|
+
return this.rpc.call('tenzro_caip19', [params]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.CaipClient = CaipClient;
|
|
29
|
+
//# sourceMappingURL=caip.js.map
|
package/dist/caip.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caip.js","sourceRoot":"","sources":["../src/caip.ts"],"names":[],"mappings":";;;AA+BA;;;;;;;;GAQG;AACH,MAAa,UAAU;IACQ;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAY,cAAc,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAa,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAqB;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAa,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AAdD,gCAcC"}
|
package/dist/canton.d.ts
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
import type { RpcClient } from './rpc';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CantonDomainList, DamlCommandParams, DamlCommandResult, DamlContractsResponse, ListDamlContractsParams } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Client for Canton / DAML enterprise ledger operations.
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* Interacts with the shared Canton participant the Tenzro node is configured
|
|
7
|
+
* against. The node proxies all calls using its own bearer JWT — callers never
|
|
8
|
+
* see the Auth0 secret.
|
|
6
9
|
*
|
|
7
10
|
* Uses Canton 3.x JSON Ledger API v2 endpoints:
|
|
8
|
-
* - Commands:
|
|
9
|
-
* - Active contracts
|
|
10
|
-
* - Events:
|
|
11
|
+
* - Commands: `POST /v2/commands/submit-and-wait-for-transaction`
|
|
12
|
+
* - Active contracts:`POST /v2/state/active-contracts` (with `identifierFilter`)
|
|
13
|
+
* - Events: `POST /v2/events/events-by-contract-id`
|
|
11
14
|
*/
|
|
12
15
|
export declare class CantonClient {
|
|
13
16
|
private readonly rpc;
|
|
14
17
|
constructor(rpc: RpcClient);
|
|
15
18
|
/**
|
|
16
|
-
* List
|
|
17
|
-
*
|
|
19
|
+
* List the Canton synchronizer domains this node is configured against.
|
|
20
|
+
*
|
|
21
|
+
* The envelope is returned even when Canton is not enabled — check
|
|
22
|
+
* `enabled` on the response before treating `domains` as live.
|
|
18
23
|
*/
|
|
19
|
-
listDomains(): Promise<
|
|
24
|
+
listDomains(): Promise<CantonDomainList>;
|
|
20
25
|
/**
|
|
21
|
-
*
|
|
22
|
-
* Queries the Canton 3.x active-contracts endpoint with `identifierFilter`
|
|
23
|
-
* for template-based filtering.
|
|
24
|
-
* @param params - Optional filter by domain, template, party, with pagination
|
|
25
|
-
* @returns Array of DAML contracts
|
|
26
|
+
* Query active DAML contracts. Requires at least one template id.
|
|
26
27
|
*/
|
|
27
|
-
listContracts(params
|
|
28
|
+
listContracts(params: ListDamlContractsParams): Promise<DamlContractsResponse>;
|
|
28
29
|
/**
|
|
29
|
-
* Submit a DAML
|
|
30
|
-
* Uses the Canton 3.x `submit-and-wait-for-transaction` endpoint.
|
|
31
|
-
* @param params - Command parameters including domain, template, payload, and optional choice
|
|
32
|
-
* @returns Command result with status and events
|
|
30
|
+
* Submit a DAML `create` or `exercise` command to the Canton participant.
|
|
33
31
|
*/
|
|
34
32
|
submitCommand(params: DamlCommandParams): Promise<DamlCommandResult>;
|
|
35
33
|
}
|
package/dist/canton.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canton.d.ts","sourceRoot":"","sources":["../src/canton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"canton.d.ts","sourceRoot":"","sources":["../src/canton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C;;;;;OAKG;IACG,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAI9C;;OAEG;IACG,aAAa,CACjB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,qBAAqB,CAAC;IAOjC;;OAEG;IACG,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAM3E"}
|
package/dist/canton.js
CHANGED
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CantonClient = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Client for Canton / DAML enterprise ledger operations.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* Interacts with the shared Canton participant the Tenzro node is configured
|
|
8
|
+
* against. The node proxies all calls using its own bearer JWT — callers never
|
|
9
|
+
* see the Auth0 secret.
|
|
7
10
|
*
|
|
8
11
|
* Uses Canton 3.x JSON Ledger API v2 endpoints:
|
|
9
|
-
* - Commands:
|
|
10
|
-
* - Active contracts
|
|
11
|
-
* - Events:
|
|
12
|
+
* - Commands: `POST /v2/commands/submit-and-wait-for-transaction`
|
|
13
|
+
* - Active contracts:`POST /v2/state/active-contracts` (with `identifierFilter`)
|
|
14
|
+
* - Events: `POST /v2/events/events-by-contract-id`
|
|
12
15
|
*/
|
|
13
16
|
class CantonClient {
|
|
14
17
|
rpc;
|
|
@@ -16,30 +19,25 @@ class CantonClient {
|
|
|
16
19
|
this.rpc = rpc;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
|
-
* List
|
|
20
|
-
*
|
|
22
|
+
* List the Canton synchronizer domains this node is configured against.
|
|
23
|
+
*
|
|
24
|
+
* The envelope is returned even when Canton is not enabled — check
|
|
25
|
+
* `enabled` on the response before treating `domains` as live.
|
|
21
26
|
*/
|
|
22
27
|
async listDomains() {
|
|
23
|
-
return this.rpc.call('tenzro_listCantonDomains',
|
|
28
|
+
return this.rpc.call('tenzro_listCantonDomains', {});
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
26
|
-
*
|
|
27
|
-
* Queries the Canton 3.x active-contracts endpoint with `identifierFilter`
|
|
28
|
-
* for template-based filtering.
|
|
29
|
-
* @param params - Optional filter by domain, template, party, with pagination
|
|
30
|
-
* @returns Array of DAML contracts
|
|
31
|
+
* Query active DAML contracts. Requires at least one template id.
|
|
31
32
|
*/
|
|
32
33
|
async listContracts(params) {
|
|
33
|
-
return this.rpc.call('tenzro_listDamlContracts',
|
|
34
|
+
return this.rpc.call('tenzro_listDamlContracts', params);
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
|
-
* Submit a DAML
|
|
37
|
-
* Uses the Canton 3.x `submit-and-wait-for-transaction` endpoint.
|
|
38
|
-
* @param params - Command parameters including domain, template, payload, and optional choice
|
|
39
|
-
* @returns Command result with status and events
|
|
37
|
+
* Submit a DAML `create` or `exercise` command to the Canton participant.
|
|
40
38
|
*/
|
|
41
39
|
async submitCommand(params) {
|
|
42
|
-
return this.rpc.call('tenzro_submitDamlCommand',
|
|
40
|
+
return this.rpc.call('tenzro_submitDamlCommand', params);
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
exports.CantonClient = CantonClient;
|
package/dist/canton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canton.js","sourceRoot":"","sources":["../src/canton.ts"],"names":[],"mappings":";;;AASA
|
|
1
|
+
{"version":3,"file":"canton.js","sourceRoot":"","sources":["../src/canton.ts"],"names":[],"mappings":";;;AASA;;;;;;;;;;;GAWG;AACH,MAAa,YAAY;IACM;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;;;OAKG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAmB,0BAA0B,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CACjB,MAA+B;QAE/B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAClB,0BAA0B,EAC1B,MAA4C,CAC7C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,MAAyB;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAClB,0BAA0B,EAC1B,MAA4C,CAC7C,CAAC;IACJ,CAAC;CACF;AAlCD,oCAkCC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { RpcClient } from './rpc';
|
|
2
|
+
/**
|
|
3
|
+
* Side of a capital intent leg.
|
|
4
|
+
*/
|
|
5
|
+
export type CapitalSide = 'acquire' | 'exit';
|
|
6
|
+
/**
|
|
7
|
+
* A weighted asset entry in a Capital Intent basket.
|
|
8
|
+
*/
|
|
9
|
+
export interface AssetWeight {
|
|
10
|
+
asset_id: string;
|
|
11
|
+
weight_bps: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Objective of a Capital Intent — the high-level outcome the principal authorizes.
|
|
15
|
+
*/
|
|
16
|
+
export type CapitalObjective = {
|
|
17
|
+
kind: 'acquire';
|
|
18
|
+
basket: AssetWeight[];
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'exit';
|
|
21
|
+
basket: AssetWeight[];
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'rebalance';
|
|
24
|
+
target: AssetWeight[];
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'hedge';
|
|
27
|
+
basket: AssetWeight[];
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'yield';
|
|
30
|
+
basket: AssetWeight[];
|
|
31
|
+
};
|
|
32
|
+
export interface CapitalConstraints {
|
|
33
|
+
max_price?: number;
|
|
34
|
+
max_eta_secs?: number;
|
|
35
|
+
max_slippage_bps?: number;
|
|
36
|
+
[extra: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
export interface CapitalComplianceReq {
|
|
39
|
+
reg_regime?: string;
|
|
40
|
+
required_kya?: string[];
|
|
41
|
+
jurisdictions?: string[];
|
|
42
|
+
[extra: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
export interface CapitalAuthorization {
|
|
45
|
+
principal_did: string;
|
|
46
|
+
signature: string;
|
|
47
|
+
expires_at: number;
|
|
48
|
+
}
|
|
49
|
+
export interface CapitalSettlementReq {
|
|
50
|
+
payer: string;
|
|
51
|
+
payee?: string;
|
|
52
|
+
asset_id: string;
|
|
53
|
+
amount: string;
|
|
54
|
+
channel?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The full Capital Intent payload — the capital-markets analog of an
|
|
58
|
+
* AP2 Intent Mandate.
|
|
59
|
+
*/
|
|
60
|
+
export interface CapitalIntent {
|
|
61
|
+
intent_id?: string;
|
|
62
|
+
objective: CapitalObjective;
|
|
63
|
+
constraints: CapitalConstraints;
|
|
64
|
+
compliance: CapitalComplianceReq;
|
|
65
|
+
authorization: CapitalAuthorization;
|
|
66
|
+
settlement_req: CapitalSettlementReq;
|
|
67
|
+
[extra: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Solver bid against an opened intent.
|
|
71
|
+
*/
|
|
72
|
+
export interface CapitalQuote {
|
|
73
|
+
solver_did: string;
|
|
74
|
+
plan: string;
|
|
75
|
+
price: number;
|
|
76
|
+
eta_secs: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Single execution leg.
|
|
80
|
+
*/
|
|
81
|
+
export interface CapitalLeg {
|
|
82
|
+
venue: string;
|
|
83
|
+
asset_id: string;
|
|
84
|
+
side: CapitalSide;
|
|
85
|
+
quantity: string;
|
|
86
|
+
unit_price: string;
|
|
87
|
+
settlement_ref?: string;
|
|
88
|
+
proof?: unknown;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 1:1-backed reserve attestation that gates `attestedMint`.
|
|
92
|
+
*/
|
|
93
|
+
export interface ReserveAttestation {
|
|
94
|
+
asset_id: string;
|
|
95
|
+
source: string;
|
|
96
|
+
amount: string;
|
|
97
|
+
attester_did: string;
|
|
98
|
+
signature: string;
|
|
99
|
+
attested_at: number;
|
|
100
|
+
proof?: unknown;
|
|
101
|
+
[extra: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Capital Intent + Reserve client.
|
|
105
|
+
*
|
|
106
|
+
* `CapitalIntent` is the capital-markets analog of an AP2 Intent Mandate:
|
|
107
|
+
* a signed, expiring authorization that says "I want to acquire / exit /
|
|
108
|
+
* rebalance / hedge / yield this basket, subject to these regulatory
|
|
109
|
+
* constraints, KYA, and ceilings." Solvers bid; the principal (or an
|
|
110
|
+
* authorized assigner) picks one; the intent runs through Execute → Settle
|
|
111
|
+
* with optional Verify and Compensate steps.
|
|
112
|
+
*
|
|
113
|
+
* Companion read paths:
|
|
114
|
+
* - `getCapitalIntent` for the current intent state.
|
|
115
|
+
* - `getReserve` / `submitReserveAttestation` for the 1:1-backed
|
|
116
|
+
* reserve attestations that underpin `attestedMint`.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const capital = client.capital;
|
|
121
|
+
*
|
|
122
|
+
* // Submit a signed intent (already authorized + signed by the principal).
|
|
123
|
+
* const opened = await capital.open(myIntent);
|
|
124
|
+
*
|
|
125
|
+
* // Solver bids; assigner picks the best one (auto-rank).
|
|
126
|
+
* const assigned = await capital.assign(opened.intent_id, { auto: true });
|
|
127
|
+
*
|
|
128
|
+
* // Execute, settle.
|
|
129
|
+
* await capital.execute(opened.intent_id, leg);
|
|
130
|
+
* await capital.settle(opened.intent_id);
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare class CapitalClient {
|
|
134
|
+
private readonly rpc;
|
|
135
|
+
constructor(rpc: RpcClient);
|
|
136
|
+
/** Open a new Capital Intent. */
|
|
137
|
+
open(intent: CapitalIntent): Promise<unknown>;
|
|
138
|
+
/** Submit a solver bid against an opened intent. */
|
|
139
|
+
quote(intentId: string, solverDid: string, plan: string, price: number, etaSecs: number): Promise<unknown>;
|
|
140
|
+
/**
|
|
141
|
+
* Assign the intent to a solver. Pass `{ auto: true }` (with no `solverDid`)
|
|
142
|
+
* to auto-rank by ERC-8004 reputation, then price, then eta.
|
|
143
|
+
*/
|
|
144
|
+
assign(intentId: string, opts?: {
|
|
145
|
+
solverDid?: string;
|
|
146
|
+
auto?: boolean;
|
|
147
|
+
payer?: string;
|
|
148
|
+
payee?: string;
|
|
149
|
+
}): Promise<unknown>;
|
|
150
|
+
/** Execute a single leg of an assigned intent. */
|
|
151
|
+
execute(intentId: string, leg: CapitalLeg): Promise<unknown>;
|
|
152
|
+
/** Verify a step. */
|
|
153
|
+
verify(intentId: string): Promise<unknown>;
|
|
154
|
+
/** Compensate (roll back) a step that failed verification. */
|
|
155
|
+
compensate(intentId: string): Promise<unknown>;
|
|
156
|
+
/** Settle the intent — release escrow to the payee. */
|
|
157
|
+
settle(intentId: string, payee?: string): Promise<unknown>;
|
|
158
|
+
/** Read the current state of a capital intent. */
|
|
159
|
+
get(intentId: string): Promise<unknown>;
|
|
160
|
+
/** Submit a 1:1-backed reserve attestation for a tokenized asset. */
|
|
161
|
+
submitReserveAttestation(attestation: ReserveAttestation): Promise<unknown>;
|
|
162
|
+
/** Read the latest reserve attestation for a tokenized asset. */
|
|
163
|
+
getReserve(assetId: string): Promise<unknown>;
|
|
164
|
+
/** Attested 1:1 mint — token issuance gated by a fresh reserve attestation. */
|
|
165
|
+
attestedMint(tokenId: string, to: string, amount: string, caller: string): Promise<unknown>;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=capital.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capital.d.ts","sourceRoot":"","sources":["../src/capital.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,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
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CapitalClient = void 0;
|
|
4
|
+
// ── Client ──
|
|
5
|
+
/**
|
|
6
|
+
* Capital Intent + Reserve client.
|
|
7
|
+
*
|
|
8
|
+
* `CapitalIntent` is the capital-markets analog of an AP2 Intent Mandate:
|
|
9
|
+
* a signed, expiring authorization that says "I want to acquire / exit /
|
|
10
|
+
* rebalance / hedge / yield this basket, subject to these regulatory
|
|
11
|
+
* constraints, KYA, and ceilings." Solvers bid; the principal (or an
|
|
12
|
+
* authorized assigner) picks one; the intent runs through Execute → Settle
|
|
13
|
+
* with optional Verify and Compensate steps.
|
|
14
|
+
*
|
|
15
|
+
* Companion read paths:
|
|
16
|
+
* - `getCapitalIntent` for the current intent state.
|
|
17
|
+
* - `getReserve` / `submitReserveAttestation` for the 1:1-backed
|
|
18
|
+
* reserve attestations that underpin `attestedMint`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const capital = client.capital;
|
|
23
|
+
*
|
|
24
|
+
* // Submit a signed intent (already authorized + signed by the principal).
|
|
25
|
+
* const opened = await capital.open(myIntent);
|
|
26
|
+
*
|
|
27
|
+
* // Solver bids; assigner picks the best one (auto-rank).
|
|
28
|
+
* const assigned = await capital.assign(opened.intent_id, { auto: true });
|
|
29
|
+
*
|
|
30
|
+
* // Execute, settle.
|
|
31
|
+
* await capital.execute(opened.intent_id, leg);
|
|
32
|
+
* await capital.settle(opened.intent_id);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
class CapitalClient {
|
|
36
|
+
rpc;
|
|
37
|
+
constructor(rpc) {
|
|
38
|
+
this.rpc = rpc;
|
|
39
|
+
}
|
|
40
|
+
/** Open a new Capital Intent. */
|
|
41
|
+
async open(intent) {
|
|
42
|
+
return this.rpc.call('tenzro_capitalIntentOpen', { intent });
|
|
43
|
+
}
|
|
44
|
+
/** Submit a solver bid against an opened intent. */
|
|
45
|
+
async quote(intentId, solverDid, plan, price, etaSecs) {
|
|
46
|
+
return this.rpc.call('tenzro_capitalIntentQuote', {
|
|
47
|
+
intent_id: intentId,
|
|
48
|
+
solver_did: solverDid,
|
|
49
|
+
plan,
|
|
50
|
+
price,
|
|
51
|
+
eta_secs: etaSecs,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Assign the intent to a solver. Pass `{ auto: true }` (with no `solverDid`)
|
|
56
|
+
* to auto-rank by ERC-8004 reputation, then price, then eta.
|
|
57
|
+
*/
|
|
58
|
+
async assign(intentId, opts = {}) {
|
|
59
|
+
const params = { intent_id: intentId };
|
|
60
|
+
if (opts.solverDid !== undefined)
|
|
61
|
+
params.solver_did = opts.solverDid;
|
|
62
|
+
if (opts.auto !== undefined)
|
|
63
|
+
params.auto = opts.auto;
|
|
64
|
+
if (opts.payer !== undefined)
|
|
65
|
+
params.payer = opts.payer;
|
|
66
|
+
if (opts.payee !== undefined)
|
|
67
|
+
params.payee = opts.payee;
|
|
68
|
+
return this.rpc.call('tenzro_capitalIntentAssign', params);
|
|
69
|
+
}
|
|
70
|
+
/** Execute a single leg of an assigned intent. */
|
|
71
|
+
async execute(intentId, leg) {
|
|
72
|
+
return this.rpc.call('tenzro_capitalIntentExecute', {
|
|
73
|
+
intent_id: intentId,
|
|
74
|
+
leg,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** Verify a step. */
|
|
78
|
+
async verify(intentId) {
|
|
79
|
+
return this.rpc.call('tenzro_capitalIntentVerify', { intent_id: intentId });
|
|
80
|
+
}
|
|
81
|
+
/** Compensate (roll back) a step that failed verification. */
|
|
82
|
+
async compensate(intentId) {
|
|
83
|
+
return this.rpc.call('tenzro_capitalIntentCompensate', {
|
|
84
|
+
intent_id: intentId,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** Settle the intent — release escrow to the payee. */
|
|
88
|
+
async settle(intentId, payee) {
|
|
89
|
+
const params = { intent_id: intentId };
|
|
90
|
+
if (payee !== undefined)
|
|
91
|
+
params.payee = payee;
|
|
92
|
+
return this.rpc.call('tenzro_capitalIntentSettle', params);
|
|
93
|
+
}
|
|
94
|
+
/** Read the current state of a capital intent. */
|
|
95
|
+
async get(intentId) {
|
|
96
|
+
return this.rpc.call('tenzro_getCapitalIntent', { intent_id: intentId });
|
|
97
|
+
}
|
|
98
|
+
/** Submit a 1:1-backed reserve attestation for a tokenized asset. */
|
|
99
|
+
async submitReserveAttestation(attestation) {
|
|
100
|
+
return this.rpc.call('tenzro_submitReserveAttestation', { attestation });
|
|
101
|
+
}
|
|
102
|
+
/** Read the latest reserve attestation for a tokenized asset. */
|
|
103
|
+
async getReserve(assetId) {
|
|
104
|
+
return this.rpc.call('tenzro_getReserve', { asset_id: assetId });
|
|
105
|
+
}
|
|
106
|
+
/** Attested 1:1 mint — token issuance gated by a fresh reserve attestation. */
|
|
107
|
+
async attestedMint(tokenId, to, amount, caller) {
|
|
108
|
+
return this.rpc.call('tenzro_attestedMint', {
|
|
109
|
+
token_id: tokenId,
|
|
110
|
+
to,
|
|
111
|
+
amount,
|
|
112
|
+
caller,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.CapitalClient = CapitalClient;
|
|
117
|
+
//# sourceMappingURL=capital.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capital.js","sourceRoot":"","sources":["../src/capital.ts"],"names":[],"mappings":";;;AA0GA,eAAe;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,aAAa;IACK;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C,iCAAiC;IACjC,KAAK,CAAC,IAAI,CAAC,MAAqB;QAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,oDAAoD;IACp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