@agoric/portfolio-api 0.2.0 → 0.2.1-upgrade-23-dev-bd79330.0.bd79330
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/package.json +26 -28
- package/src/constants.d.ts +115 -0
- package/src/constants.d.ts.map +1 -0
- package/src/constants.js +170 -13
- package/src/evm/types.d.ts +19 -0
- package/src/evm/types.d.ts.map +1 -0
- package/src/evm/types.js +27 -0
- package/src/evm-wallet/eip712-messages.d.ts +213 -0
- package/src/evm-wallet/eip712-messages.d.ts.map +1 -0
- package/src/evm-wallet/eip712-messages.js +355 -0
- package/src/evm-wallet/message-handler-helpers.d.ts +54 -0
- package/src/evm-wallet/message-handler-helpers.d.ts.map +1 -0
- package/src/evm-wallet/message-handler-helpers.js +289 -0
- package/src/instruments.d.ts +54 -0
- package/src/instruments.d.ts.map +1 -0
- package/src/instruments.js +69 -0
- package/src/main.d.ts +6 -0
- package/src/main.d.ts.map +1 -0
- package/src/main.js +6 -1
- package/src/model/generated/ymax-machine.d.ts +71 -0
- package/src/model/generated/ymax-machine.d.ts.map +1 -0
- package/src/model/generated/ymax-machine.js +1292 -0
- package/src/model/ymax-machine.mmd +56 -0
- package/src/model/ymax-machine.schema.json +180 -0
- package/src/model/ymax-machine.yaml +942 -0
- package/src/portfolio-constants.d.ts +44 -0
- package/src/portfolio-constants.d.ts.map +1 -0
- package/src/portfolio-constants.js +80 -0
- package/src/resolver.d.ts +159 -0
- package/src/resolver.d.ts.map +1 -0
- package/src/resolver.js +115 -0
- package/src/type-guards.d.ts +39 -0
- package/src/type-guards.d.ts.map +1 -0
- package/src/type-guards.js +71 -0
- package/src/types.d.ts +296 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.js +337 -0
- package/src/types.ts +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Constants and configuration for portfolio contract deployment
|
|
3
|
+
*
|
|
4
|
+
* This module exports domain knowledge about portfolio contract deployment,
|
|
5
|
+
* including wallet store keys, control addresses, and contract names.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Wallet store key where the contract control facet is delivered
|
|
9
|
+
* @type {string}
|
|
10
|
+
*/
|
|
11
|
+
export const YMAX_CONTROL_WALLET_KEY: string;
|
|
12
|
+
/**
|
|
13
|
+
* Known portfolio contract names in agoricNames.instance
|
|
14
|
+
* @type {readonly ['ymax0', 'ymax1']}
|
|
15
|
+
*/
|
|
16
|
+
export const PORTFOLIO_CONTRACT_NAMES: readonly ["ymax0", "ymax1"];
|
|
17
|
+
/**
|
|
18
|
+
* Control account addresses per contract and network
|
|
19
|
+
* Source: https://www.mintscan.io/agoric/proposals/111 (for ymax0/main)
|
|
20
|
+
*
|
|
21
|
+
* @type {{
|
|
22
|
+
* ymax0: {
|
|
23
|
+
* main: string;
|
|
24
|
+
* devnet: string;
|
|
25
|
+
* };
|
|
26
|
+
* ymax1: {
|
|
27
|
+
* main: string;
|
|
28
|
+
* devnet: string;
|
|
29
|
+
* };
|
|
30
|
+
* }}
|
|
31
|
+
*/
|
|
32
|
+
export const CONTROL_ADDRESSES: {
|
|
33
|
+
ymax0: {
|
|
34
|
+
main: string;
|
|
35
|
+
devnet: string;
|
|
36
|
+
};
|
|
37
|
+
ymax1: {
|
|
38
|
+
main: string;
|
|
39
|
+
devnet: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export function getControlAddress(contractName: (typeof PORTFOLIO_CONTRACT_NAMES)[number], network: "main" | "devnet"): string;
|
|
43
|
+
export function isPortfolioContract(name: string): name is "ymax0" | "ymax1";
|
|
44
|
+
//# sourceMappingURL=portfolio-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portfolio-constants.d.ts","sourceRoot":"","sources":["portfolio-constants.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,sCAFU,MAAM,CAEqC;AAErD;;;GAGG;AACH,uCAFU,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAKlC;AAEH;;;;;;;;;;;;;;GAcG;AACH,gCAXU;IACL,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAWF;AAUK,gDALI,CAAA,OAAO,wBAAwB,EAAC,MAAM,CAAC,WACvC,MAAM,GAAG,QAAQ,GACf,MAAM,CAclB;AAQM,0CAHI,MAAM,6BAOhB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Constants and configuration for portfolio contract deployment
|
|
3
|
+
*
|
|
4
|
+
* This module exports domain knowledge about portfolio contract deployment,
|
|
5
|
+
* including wallet store keys, control addresses, and contract names.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wallet store key where the contract control facet is delivered
|
|
10
|
+
* @type {string}
|
|
11
|
+
*/
|
|
12
|
+
export const YMAX_CONTROL_WALLET_KEY = 'ymaxControl';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Known portfolio contract names in agoricNames.instance
|
|
16
|
+
* @type {readonly ['ymax0', 'ymax1']}
|
|
17
|
+
*/
|
|
18
|
+
export const PORTFOLIO_CONTRACT_NAMES = /** @type {const} */ ([
|
|
19
|
+
'ymax0',
|
|
20
|
+
'ymax1',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Control account addresses per contract and network
|
|
25
|
+
* Source: https://www.mintscan.io/agoric/proposals/111 (for ymax0/main)
|
|
26
|
+
*
|
|
27
|
+
* @type {{
|
|
28
|
+
* ymax0: {
|
|
29
|
+
* main: string;
|
|
30
|
+
* devnet: string;
|
|
31
|
+
* };
|
|
32
|
+
* ymax1: {
|
|
33
|
+
* main: string;
|
|
34
|
+
* devnet: string;
|
|
35
|
+
* };
|
|
36
|
+
* }}
|
|
37
|
+
*/
|
|
38
|
+
export const CONTROL_ADDRESSES = {
|
|
39
|
+
ymax0: {
|
|
40
|
+
main: 'agoric1e80twfutmrm3wrk3fysjcnef4j82mq8dn6nmcq',
|
|
41
|
+
devnet: 'agoric10utru593dspjwfewcgdak8lvp9tkz0xttvcnxv',
|
|
42
|
+
},
|
|
43
|
+
ymax1: {
|
|
44
|
+
main: 'agoric18dx5f8ck5xy2dgkgeyp2w478dztxv3z2mnz928',
|
|
45
|
+
devnet: 'agoric1awsr6hpn4t44jfrrnf5xr70mz4zrg5glvft6sl',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get the control address for a contract on a specific network
|
|
51
|
+
*
|
|
52
|
+
* @param {typeof PORTFOLIO_CONTRACT_NAMES[number]} contractName
|
|
53
|
+
* @param {'main' | 'devnet'} network
|
|
54
|
+
* @returns {string} The control account address
|
|
55
|
+
* @throws {Error} If contract or network is invalid
|
|
56
|
+
*/
|
|
57
|
+
export const getControlAddress = (contractName, network) => {
|
|
58
|
+
if (!PORTFOLIO_CONTRACT_NAMES.includes(contractName)) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Invalid contract name: ${contractName}. Must be one of: ${PORTFOLIO_CONTRACT_NAMES.join(', ')}`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if (network !== 'main' && network !== 'devnet') {
|
|
64
|
+
throw new Error(`Invalid network: ${network}. Must be 'main' or 'devnet'`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return CONTROL_ADDRESSES[contractName][network];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Validate that a contract name is a known portfolio contract
|
|
72
|
+
*
|
|
73
|
+
* @param {string} name
|
|
74
|
+
* @returns {name is typeof PORTFOLIO_CONTRACT_NAMES[number]}
|
|
75
|
+
*/
|
|
76
|
+
export const isPortfolioContract = name => {
|
|
77
|
+
return PORTFOLIO_CONTRACT_NAMES.includes(
|
|
78
|
+
/** @type {typeof PORTFOLIO_CONTRACT_NAMES[number]} */ (name),
|
|
79
|
+
);
|
|
80
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Statuses for published transactions. Exhaustive state machine transitions:
|
|
3
|
+
* - setup -> pending (when transaction information is assembled and sent)
|
|
4
|
+
* - pending -> success (when cross-chain operation completes successfully)
|
|
5
|
+
* - pending -> failed (when operation fails or times out)
|
|
6
|
+
*/
|
|
7
|
+
export type TxStatus = (typeof TxStatus)[keyof typeof TxStatus];
|
|
8
|
+
export namespace TxStatus {
|
|
9
|
+
let SETUP: "setup";
|
|
10
|
+
let PENDING: "pending";
|
|
11
|
+
let SUCCESS: "success";
|
|
12
|
+
let FAILED: "failed";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Tx types for published transactions
|
|
16
|
+
*/
|
|
17
|
+
export type TxType = Readonly<(typeof TxType)[keyof typeof TxType]>;
|
|
18
|
+
/**
|
|
19
|
+
* Tx types for published transactions
|
|
20
|
+
*
|
|
21
|
+
* @enum {Readonly<(typeof TxType)[keyof typeof TxType]>}
|
|
22
|
+
*/
|
|
23
|
+
export const TxType: import("@agoric/internal").KeyMirrorResult<{
|
|
24
|
+
CCTP_TO_EVM: null;
|
|
25
|
+
GMP: null;
|
|
26
|
+
ROUTED_GMP: null;
|
|
27
|
+
CCTP_TO_AGORIC: null;
|
|
28
|
+
IBC_FROM_AGORIC: null;
|
|
29
|
+
IBC_FROM_REMOTE: null;
|
|
30
|
+
MAKE_ACCOUNT: null;
|
|
31
|
+
/**
|
|
32
|
+
* Placeholder for ProgressTracker protocols not yet recognized by the
|
|
33
|
+
* resolver client, just so they can be published to vstorage, but not
|
|
34
|
+
* processed any further. If these appear, it means the resolver client
|
|
35
|
+
* source code needs to be updated.
|
|
36
|
+
*/
|
|
37
|
+
UNKNOWN: null;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Adapt orchestration TrafficEntry to the portfolio's PublishedTx type.
|
|
41
|
+
* - Rename 'dst' to 'dest' for consistency with portfolio-contract.
|
|
42
|
+
* - Add optional 'amount' property.
|
|
43
|
+
*/
|
|
44
|
+
export type PublishedTrafficTxDetails = Partial<Omit<TrafficEntry, "dst">> & {
|
|
45
|
+
type: TxType & ("IBC_FROM_AGORIC" | "IBC_FROM_REMOTE");
|
|
46
|
+
dest?: TrafficEntry["dst"];
|
|
47
|
+
amount?: bigint;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Represents a transaction published in vstorage at
|
|
51
|
+
* `published.${contractInstance}.pendingTxs.tx${number}`
|
|
52
|
+
* with its type, optional amount, destination, and status.
|
|
53
|
+
*/
|
|
54
|
+
export type PublishedPortfolioTxDetails = {
|
|
55
|
+
/**
|
|
56
|
+
* - The type of
|
|
57
|
+
* transaction (CCTP_TO_EVM, GMP, CCTP_TO_AGORIC, or MAKE_ACCOUNT)
|
|
58
|
+
*/
|
|
59
|
+
type: Exclude<TxType, PublishedTrafficTxDetails["type"] | "ROUTED_GMP">;
|
|
60
|
+
/**
|
|
61
|
+
* - Optional transaction amount as a bigint, currently in micro-USDC (6 decimal fixed-point)
|
|
62
|
+
*/
|
|
63
|
+
amount?: bigint | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* - The destination account
|
|
66
|
+
* identifier for the transaction
|
|
67
|
+
*/
|
|
68
|
+
destinationAddress?: `${string}:${string}:${string}` | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* - The source LCA address initiating the
|
|
71
|
+
* transaction (required for GMP and MAKE_ACCOUNT transactions)
|
|
72
|
+
*/
|
|
73
|
+
sourceAddress?: `${string}:${string}:${string}` | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* - The expected address of the EVM smart
|
|
76
|
+
* wallet to be created (only for type "MAKE_ACCOUNT")
|
|
77
|
+
*/
|
|
78
|
+
expectedAddr?: `0x${string}` | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* - The address of the EVM smart wallet
|
|
81
|
+
* factory contract responsible for creating the smart wallet (only for type
|
|
82
|
+
* "MAKE_ACCOUNT")
|
|
83
|
+
*/
|
|
84
|
+
factoryAddr?: `0x${string}` | undefined;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Core debugging details that every pending ROUTED_GMP transaction publish
|
|
88
|
+
*/
|
|
89
|
+
export type RoutedGMPTxBaseDetails = {
|
|
90
|
+
/**
|
|
91
|
+
* - The 4-byte function selector of the process instruction function
|
|
92
|
+
*/
|
|
93
|
+
instructionSelector: `0x${string}`;
|
|
94
|
+
/**
|
|
95
|
+
* - The routed instruction type
|
|
96
|
+
*/
|
|
97
|
+
instructionType: SupportedInstructions;
|
|
98
|
+
/**
|
|
99
|
+
* - The EVM address corresponding to the source LCA address
|
|
100
|
+
*/
|
|
101
|
+
expectedRemoteTargetAddress: HexAddress;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Specialized case of a transaction published in vstorage at
|
|
105
|
+
* `published.${contractInstance}.pendingTxs.tx${number}`
|
|
106
|
+
* for the ROUTED_GMP type.
|
|
107
|
+
*/
|
|
108
|
+
export type PublishedRoutedGMPTxDetails = {
|
|
109
|
+
/**
|
|
110
|
+
* - The type of transaction, always "ROUTED_GMP"
|
|
111
|
+
*/
|
|
112
|
+
type: TxType & ("ROUTED_GMP");
|
|
113
|
+
/**
|
|
114
|
+
* - The router account handling this transaction
|
|
115
|
+
*/
|
|
116
|
+
destinationAddress: AccountId;
|
|
117
|
+
/**
|
|
118
|
+
* - The source LCA address initiating the
|
|
119
|
+
* transaction (either portfolio or contract)
|
|
120
|
+
*/
|
|
121
|
+
sourceAddress: AccountId;
|
|
122
|
+
/**
|
|
123
|
+
* - Flag indicating that the initial transaction registration is incomplete and awaiting payloadHash and details update
|
|
124
|
+
*/
|
|
125
|
+
incomplete?: true | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* - The hash of the GMP Payload
|
|
128
|
+
*/
|
|
129
|
+
payloadHash?: `0x${string}` | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* - Debugging details
|
|
132
|
+
*/
|
|
133
|
+
details?: (RoutedGMPTxBaseDetails & Record<string, PureData>) | undefined;
|
|
134
|
+
};
|
|
135
|
+
export type PublishedTxBase = {
|
|
136
|
+
/**
|
|
137
|
+
* - The type of transaction (CCTP_TO_EVM, GMP, CCTP_TO_AGORIC, or MAKE_ACCOUNT)
|
|
138
|
+
*/
|
|
139
|
+
type: TxType;
|
|
140
|
+
/**
|
|
141
|
+
* - Current status of the transaction (pending, success, or failed)
|
|
142
|
+
*/
|
|
143
|
+
status: TxStatus;
|
|
144
|
+
/**
|
|
145
|
+
* - Optional reason for failure (only present when status is 'failed')
|
|
146
|
+
*/
|
|
147
|
+
rejectionReason?: string | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* - DEPRECATED in favor of {@link import ('./types.js').FlowStep['phases']}. Optional ID of the next transaction in a sequence
|
|
150
|
+
*/
|
|
151
|
+
nextTxId?: `tx${number}` | undefined;
|
|
152
|
+
};
|
|
153
|
+
export type PublishedTx = PublishedTxBase & (PublishedTrafficTxDetails | PublishedPortfolioTxDetails | PublishedRoutedGMPTxDetails);
|
|
154
|
+
import type { TrafficEntry } from '@agoric/orchestration';
|
|
155
|
+
import type { SupportedInstructions } from '@aglocal/portfolio-contract/src/interfaces/orch-router.js';
|
|
156
|
+
import type { HexAddress } from '@agoric/orchestration';
|
|
157
|
+
import type { AccountId } from '@agoric/orchestration';
|
|
158
|
+
import type { PureData } from '@endo/pass-style';
|
|
159
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["resolver.js"],"names":[],"mappings":";;;;;;uBAeU,CAAC,OAAO,QAAQ,EAAE,MAAM,OAAO,QAAQ,CAAC;;;;;;;;;;qBAaxC,QAAQ,CAAC,CAAC,OAAO,MAAM,EAAE,MAAM,OAAO,MAAM,CAAC,CAAC;AAHxD;;;;GAIG;AACH;;;;;;;;IAQE;;;;;OAKG;;GAEF;;;;;;wCAIU,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,GAAG;IAC7C,IAAI,EAAE,MAAM,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;IACvD,IAAI,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;;;;;;;;;;UAYU,OAAO,CAAC,MAAM,EAAE,yBAAyB,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAkBjE,KAAK,MAAM,EAAE;;;;qBACb,qBAAqB;;;;iCACrB,UAAU;;;;;;;;;;;UASV,MAAM,GAAG,CAAC,YAAY,CAAC;;;;wBACvB,SAAS;;;;;mBACT,SAAS;;;;;;;;;;;;;;;;;;UAUT,MAAM;;;;YACN,QAAQ;;;;;;;;;;0BAMT,eAAe,GAAG,CAAC,yBAAyB,GAAG,2BAA2B,GAAG,2BAA2B,CAAC;kCA7GhE,uBAAuB;2CAErC,2DAA2D;gCAF7C,uBAAuB;+BAAvB,uBAAuB;8BADlD,kBAAkB"}
|
package/src/resolver.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { keyMirror } from '@agoric/internal';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @import {PureData} from '@endo/pass-style';
|
|
5
|
+
* @import {AccountId, HexAddress, TrafficEntry} from '@agoric/orchestration';
|
|
6
|
+
* @import {TxId} from './types.js';
|
|
7
|
+
* @import {SupportedInstructions} from '@aglocal/portfolio-contract/src/interfaces/orch-router.js';
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Statuses for published transactions. Exhaustive state machine transitions:
|
|
12
|
+
* - setup -> pending (when transaction information is assembled and sent)
|
|
13
|
+
* - pending -> success (when cross-chain operation completes successfully)
|
|
14
|
+
* - pending -> failed (when operation fails or times out)
|
|
15
|
+
*
|
|
16
|
+
* @enum {(typeof TxStatus)[keyof typeof TxStatus]}
|
|
17
|
+
*/
|
|
18
|
+
export const TxStatus = /** @type {const} */ ({
|
|
19
|
+
SETUP: 'setup',
|
|
20
|
+
PENDING: 'pending',
|
|
21
|
+
SUCCESS: 'success',
|
|
22
|
+
FAILED: 'failed',
|
|
23
|
+
});
|
|
24
|
+
harden(TxStatus);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Tx types for published transactions
|
|
28
|
+
*
|
|
29
|
+
* @enum {Readonly<(typeof TxType)[keyof typeof TxType]>}
|
|
30
|
+
*/
|
|
31
|
+
export const TxType = keyMirror({
|
|
32
|
+
CCTP_TO_EVM: null,
|
|
33
|
+
GMP: null,
|
|
34
|
+
ROUTED_GMP: null,
|
|
35
|
+
CCTP_TO_AGORIC: null,
|
|
36
|
+
IBC_FROM_AGORIC: null,
|
|
37
|
+
IBC_FROM_REMOTE: null,
|
|
38
|
+
MAKE_ACCOUNT: null,
|
|
39
|
+
/**
|
|
40
|
+
* Placeholder for ProgressTracker protocols not yet recognized by the
|
|
41
|
+
* resolver client, just so they can be published to vstorage, but not
|
|
42
|
+
* processed any further. If these appear, it means the resolver client
|
|
43
|
+
* source code needs to be updated.
|
|
44
|
+
*/
|
|
45
|
+
UNKNOWN: null,
|
|
46
|
+
});
|
|
47
|
+
harden(TxType);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {Partial<Omit<TrafficEntry, 'dst'>> & {
|
|
51
|
+
* type: TxType & ('IBC_FROM_AGORIC' | 'IBC_FROM_REMOTE');
|
|
52
|
+
* dest?: TrafficEntry['dst']
|
|
53
|
+
* amount?: bigint;
|
|
54
|
+
* }} PublishedTrafficTxDetails
|
|
55
|
+
* Adapt orchestration TrafficEntry to the portfolio's PublishedTx type.
|
|
56
|
+
* - Rename 'dst' to 'dest' for consistency with portfolio-contract.
|
|
57
|
+
* - Add optional 'amount' property.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Represents a transaction published in vstorage at
|
|
62
|
+
* `published.${contractInstance}.pendingTxs.tx${number}`
|
|
63
|
+
* with its type, optional amount, destination, and status.
|
|
64
|
+
*
|
|
65
|
+
* @typedef {object} PublishedPortfolioTxDetails
|
|
66
|
+
* @property {Exclude<TxType, PublishedTrafficTxDetails['type'] | 'ROUTED_GMP'>} type - The type of
|
|
67
|
+
* transaction (CCTP_TO_EVM, GMP, CCTP_TO_AGORIC, or MAKE_ACCOUNT)
|
|
68
|
+
* @property {bigint} [amount] - Optional transaction amount as a bigint, currently in micro-USDC (6 decimal fixed-point)
|
|
69
|
+
* @property {AccountId} [destinationAddress] - The destination account
|
|
70
|
+
* identifier for the transaction
|
|
71
|
+
* @property {AccountId} [sourceAddress] - The source LCA address initiating the
|
|
72
|
+
* transaction (required for GMP and MAKE_ACCOUNT transactions)
|
|
73
|
+
* @property {HexAddress} [expectedAddr] - The expected address of the EVM smart
|
|
74
|
+
* wallet to be created (only for type "MAKE_ACCOUNT")
|
|
75
|
+
* @property {HexAddress} [factoryAddr] - The address of the EVM smart wallet
|
|
76
|
+
* factory contract responsible for creating the smart wallet (only for type
|
|
77
|
+
* "MAKE_ACCOUNT")
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Core debugging details that every pending ROUTED_GMP transaction publish
|
|
82
|
+
*
|
|
83
|
+
* @typedef {object} RoutedGMPTxBaseDetails
|
|
84
|
+
* @property {`0x${string}`} instructionSelector - The 4-byte function selector of the process instruction function
|
|
85
|
+
* @property {SupportedInstructions} instructionType - The routed instruction type
|
|
86
|
+
* @property {HexAddress} expectedRemoteTargetAddress - The EVM address corresponding to the source LCA address
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Specialized case of a transaction published in vstorage at
|
|
91
|
+
* `published.${contractInstance}.pendingTxs.tx${number}`
|
|
92
|
+
* for the ROUTED_GMP type.
|
|
93
|
+
*
|
|
94
|
+
* @typedef {object} PublishedRoutedGMPTxDetails
|
|
95
|
+
* @property {TxType & ('ROUTED_GMP')} type - The type of transaction, always "ROUTED_GMP"
|
|
96
|
+
* @property {AccountId} destinationAddress - The router account handling this transaction
|
|
97
|
+
* @property {AccountId} sourceAddress - The source LCA address initiating the
|
|
98
|
+
* transaction (either portfolio or contract)
|
|
99
|
+
* @property {true} [incomplete] - Flag indicating that the initial transaction registration is incomplete and awaiting payloadHash and details update
|
|
100
|
+
* @property {`0x${string}`} [payloadHash] - The hash of the GMP Payload
|
|
101
|
+
* @property {RoutedGMPTxBaseDetails & Record<string, PureData>} [details] - Debugging details
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
// eslint-disable-next-line @agoric/group-jsdoc-imports
|
|
105
|
+
/**
|
|
106
|
+
* @typedef {object} PublishedTxBase
|
|
107
|
+
* @property {TxType} type - The type of transaction (CCTP_TO_EVM, GMP, CCTP_TO_AGORIC, or MAKE_ACCOUNT)
|
|
108
|
+
* @property {TxStatus} status - Current status of the transaction (pending, success, or failed)
|
|
109
|
+
* @property {string} [rejectionReason] - Optional reason for failure (only present when status is 'failed')
|
|
110
|
+
* @property {TxId} [nextTxId] - DEPRECATED in favor of {@link import('./types.js').FlowStep['phases']}. Optional ID of the next transaction in a sequence
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @typedef {PublishedTxBase & (PublishedTrafficTxDetails | PublishedPortfolioTxDetails | PublishedRoutedGMPTxDetails)} PublishedTx
|
|
115
|
+
*/
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { BeefyInstrumentId, ERC4626InstrumentId } from '@aglocal/portfolio-contract/src/type-guards.js';
|
|
2
|
+
import type { InstrumentId } from './instruments.js';
|
|
3
|
+
import type { DepositFromChainRef, LocalChainAccountRef, InterChainAccountRef, WithdrawToChainRef } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Without regard to supported chains, is the input plausibly a
|
|
6
|
+
* DepositFromChainRef (i.e., does it start with `+`)?
|
|
7
|
+
*/
|
|
8
|
+
export declare const isDepositFromChainRef: (ref: string) => ref is DepositFromChainRef;
|
|
9
|
+
/**
|
|
10
|
+
* Without regard to supported chains, is the input plausibly a
|
|
11
|
+
* LocalChainAccountRef (i.e., does it start with `+`)?
|
|
12
|
+
*/
|
|
13
|
+
export declare const isLocalChainAccountRef: (ref: string) => ref is LocalChainAccountRef;
|
|
14
|
+
/**
|
|
15
|
+
* Without regard to supported chains, is the input plausibly an
|
|
16
|
+
* InterChainAccountRef (i.e., does it start with `@`)?
|
|
17
|
+
*/
|
|
18
|
+
export declare const isInterChainAccountRef: (ref: string) => ref is InterChainAccountRef;
|
|
19
|
+
/**
|
|
20
|
+
* Without regard to supported chains, is the input plausibly an InstrumentId
|
|
21
|
+
* (i.e., does it start with an ASCII letter)?
|
|
22
|
+
*/
|
|
23
|
+
export declare const isInstrumentId: (ref: string) => ref is InstrumentId;
|
|
24
|
+
/**
|
|
25
|
+
* Without regard to supported chains, is the input plausibly a
|
|
26
|
+
* WithdrawToChainRef (i.e., does it start with `-`)?
|
|
27
|
+
*/
|
|
28
|
+
export declare const isWithdrawToChainRef: (ref: string) => ref is WithdrawToChainRef;
|
|
29
|
+
/**
|
|
30
|
+
* Is the input an ERC-4626 InstrumentId
|
|
31
|
+
* (i.e., does it start with 'ERC4626_')?
|
|
32
|
+
*/
|
|
33
|
+
export declare const isERC4626InstrumentId: (ref: string) => ref is ERC4626InstrumentId;
|
|
34
|
+
/**
|
|
35
|
+
* Is the input an Beefy InstrumentId
|
|
36
|
+
* (i.e., does it start with 'Beefy_')?
|
|
37
|
+
*/
|
|
38
|
+
export declare const isBeefyInstrumentId: (ref: string) => ref is BeefyInstrumentId;
|
|
39
|
+
//# sourceMappingURL=type-guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["type-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,KAAK,MAAM,KACV,GAAG,IAAI,mBAA0C,CAAC;AAGrD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,MAAM,KACV,GAAG,IAAI,oBAA2C,CAAC;AAGtD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,MAAM,KACV,GAAG,IAAI,oBAA2C,CAAC;AAGtD;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,GAAG,IAAI,YAC5B,CAAC;AAGzB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,KAAG,GAAG,IAAI,kBACrC,CAAC;AAGtB;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,KAAK,MAAM,KACV,GAAG,IAAI,mBAAiD,CAAC;AAG5D;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,KAAG,GAAG,IAAI,iBAC/B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Without regard to supported chains, is the input plausibly a
|
|
15
|
+
* DepositFromChainRef (i.e., does it start with `+`)?
|
|
16
|
+
*/
|
|
17
|
+
export const isDepositFromChainRef = (
|
|
18
|
+
ref ,
|
|
19
|
+
) => ref.startsWith('+');
|
|
20
|
+
harden(isDepositFromChainRef);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Without regard to supported chains, is the input plausibly a
|
|
24
|
+
* LocalChainAccountRef (i.e., does it start with `+`)?
|
|
25
|
+
*/
|
|
26
|
+
export const isLocalChainAccountRef = (
|
|
27
|
+
ref ,
|
|
28
|
+
) => ref.startsWith('+');
|
|
29
|
+
harden(isLocalChainAccountRef);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Without regard to supported chains, is the input plausibly an
|
|
33
|
+
* InterChainAccountRef (i.e., does it start with `@`)?
|
|
34
|
+
*/
|
|
35
|
+
export const isInterChainAccountRef = (
|
|
36
|
+
ref ,
|
|
37
|
+
) => ref.startsWith('@');
|
|
38
|
+
harden(isInterChainAccountRef);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Without regard to supported chains, is the input plausibly an InstrumentId
|
|
42
|
+
* (i.e., does it start with an ASCII letter)?
|
|
43
|
+
*/
|
|
44
|
+
export const isInstrumentId = (ref ) =>
|
|
45
|
+
!!ref.match(/^[a-z]/i);
|
|
46
|
+
harden(isInstrumentId);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Without regard to supported chains, is the input plausibly a
|
|
50
|
+
* WithdrawToChainRef (i.e., does it start with `-`)?
|
|
51
|
+
*/
|
|
52
|
+
export const isWithdrawToChainRef = (ref ) =>
|
|
53
|
+
ref.startsWith('-');
|
|
54
|
+
harden(isWithdrawToChainRef);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Is the input an ERC-4626 InstrumentId
|
|
58
|
+
* (i.e., does it start with 'ERC4626_')?
|
|
59
|
+
*/
|
|
60
|
+
export const isERC4626InstrumentId = (
|
|
61
|
+
ref ,
|
|
62
|
+
) => ref.startsWith('ERC4626_');
|
|
63
|
+
harden(isERC4626InstrumentId);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Is the input an Beefy InstrumentId
|
|
67
|
+
* (i.e., does it start with 'Beefy_')?
|
|
68
|
+
*/
|
|
69
|
+
export const isBeefyInstrumentId = (ref ) =>
|
|
70
|
+
ref.startsWith('Beefy_');
|
|
71
|
+
harden(isBeefyInstrumentId);
|