@bitgo/public-types 5.51.0 → 5.53.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/dist/src/schema/transactionRequest/intents/adaPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/adaStakeClaimRewardsIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/aptStakeIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/aptStakeIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/aptStakeIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/aptUnstakeIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/aptUnstakeIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/aptUnstakeIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/aptWithdrawStakeIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/aptWithdrawStakeIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/aptWithdrawStakeIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/atomPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/atomStakeIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/atomStakeIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/atomStakeIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/atomUnstakeIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/atomUnstakeIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/atomUnstakeIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/atomWithdrawIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/atomWithdrawIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/atomWithdrawIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/baseIntent.d.ts +69 -0
- package/dist/src/schema/transactionRequest/intents/baseIntent.js +23 -1
- package/dist/src/schema/transactionRequest/intents/baseIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/bscDelegateIntent.d.ts +3 -2
- package/dist/src/schema/transactionRequest/intents/bscDelegateIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/bscDelegateIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/bscStakeClaimRewardsIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/bscUndelegateIntent.d.ts +3 -2
- package/dist/src/schema/transactionRequest/intents/bscUndelegateIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/bscUndelegateIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/coredaoDelegateIntent.d.ts +3 -2
- package/dist/src/schema/transactionRequest/intents/coredaoDelegateIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/coredaoDelegateIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/coredaoUndelegateIntent.d.ts +3 -2
- package/dist/src/schema/transactionRequest/intents/coredaoUndelegateIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/coredaoUndelegateIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/cosmosPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/cosmosStakeIntent.d.ts +3 -2
- package/dist/src/schema/transactionRequest/intents/cosmosStakeIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/cosmosStakeIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/cosmosSwitchValidatorIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/cosmosUnstakeIntent.d.ts +3 -2
- package/dist/src/schema/transactionRequest/intents/cosmosUnstakeIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/cosmosUnstakeIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/dotPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/dotStakingIntent.d.ts +1 -0
- package/dist/src/schema/transactionRequest/intents/dotStakingIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/dotStakingIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/dotUnstakingIntent.d.ts +1 -0
- package/dist/src/schema/transactionRequest/intents/dotUnstakingIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/dotUnstakingIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/ethPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/ethTransferTokenIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/icpPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/intent.d.ts +77 -222
- package/dist/src/schema/transactionRequest/intents/iotaPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/mmiSignTransactionIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/paymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/paymentIntent.js +1 -3
- package/dist/src/schema/transactionRequest/intents/paymentIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/solClaimIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/solClaimIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/solClaimIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/solPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/solStakeIntent.d.ts +4 -2
- package/dist/src/schema/transactionRequest/intents/solStakeIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/solStakeIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/stakeClaimRewardsIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/stakeClaimRewardsIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/stakeClaimRewardsIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/stakeSwitchValidatorIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/stakeSwitchValidatorIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/stakeSwitchValidatorIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/substratePaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/suiPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/tokenApprovalIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/tokenApprovalIntent.js +1 -1
- package/dist/src/schema/transactionRequest/intents/tokenApprovalIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/tonDelegateIntent.d.ts +3 -2
- package/dist/src/schema/transactionRequest/intents/tonDelegateIntent.js +1 -2
- package/dist/src/schema/transactionRequest/intents/tonDelegateIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/tonPaymentIntent.d.ts +3 -18
- package/dist/src/schema/transactionRequest/intents/transferTokenIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/transferTokenIntent.js +1 -2
- package/dist/src/schema/transactionRequest/intents/transferTokenIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/intents/vetStakeClaimRewardsIntent.d.ts +2 -1
- package/dist/src/schema/transactionRequest/intents/vetStakingIntent.d.ts +1 -0
- package/dist/src/schema/transactionRequest/intents/vetStakingIntent.js +2 -2
- package/dist/src/schema/transactionRequest/intents/vetStakingIntent.js.map +1 -1
- package/dist/src/schema/transactionRequest/transactionRequest.d.ts +154 -444
- package/dist/src/schema/wallet/freeze.d.ts +11 -0
- package/dist/src/schema/wallet/freeze.js +40 -0
- package/dist/src/schema/wallet/freeze.js.map +1 -0
- package/dist/src/schema/wallet/index.d.ts +1 -0
- package/dist/src/schema/wallet/index.js +1 -0
- package/dist/src/schema/wallet/index.js.map +1 -1
- package/dist/src/utils/getAssetsFromIntent.d.ts +1 -0
- package/dist/src/utils/getAssetsFromIntent.js +45 -0
- package/dist/src/utils/getAssetsFromIntent.js.map +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/schema/transactionRequest/intents/README.md +180 -8
- package/src/schema/transactionRequest/intents/aptStakeIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/aptUnstakeIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/aptWithdrawStakeIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/atomStakeIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/atomUnstakeIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/atomWithdrawIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/baseIntent.ts +116 -0
- package/src/schema/transactionRequest/intents/bscDelegateIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/bscUndelegateIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/coredaoDelegateIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/coredaoUndelegateIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/cosmosStakeIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/cosmosUnstakeIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/dotStakingIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/dotUnstakingIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/paymentIntent.ts +2 -4
- package/src/schema/transactionRequest/intents/solClaimIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/solStakeIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/stakeClaimRewardsIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/stakeSwitchValidatorIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/tokenApprovalIntent.ts +2 -2
- package/src/schema/transactionRequest/intents/tonDelegateIntent.ts +2 -3
- package/src/schema/transactionRequest/intents/transferTokenIntent.ts +2 -3
- package/src/schema/transactionRequest/intents/vetStakingIntent.ts +2 -2
- package/src/schema/wallet/freeze.ts +20 -0
- package/src/schema/wallet/index.ts +1 -0
- package/src/utils/getAssetsFromIntent.ts +81 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const TokenTransferRecipientParams: t.IntersectionC<[t.TypeC<{
|
|
3
|
+
tokenType: t.StringC;
|
|
4
|
+
tokenQuantity: t.StringC;
|
|
5
|
+
}>, t.PartialC<{
|
|
6
|
+
tokenContractAddress: t.StringC;
|
|
7
|
+
tokenName: t.StringC;
|
|
8
|
+
tokenId: t.StringC;
|
|
9
|
+
decimalPlaces: t.NumberC;
|
|
10
|
+
}>]>;
|
|
11
|
+
export type TokenTransferRecipientParams = t.TypeOf<typeof TokenTransferRecipientParams>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.TokenTransferRecipientParams = void 0;
|
|
27
|
+
const t = __importStar(require("io-ts"));
|
|
28
|
+
exports.TokenTransferRecipientParams = t.intersection([
|
|
29
|
+
t.type({
|
|
30
|
+
tokenType: t.string,
|
|
31
|
+
tokenQuantity: t.string,
|
|
32
|
+
}),
|
|
33
|
+
t.partial({
|
|
34
|
+
tokenContractAddress: t.string,
|
|
35
|
+
tokenName: t.string,
|
|
36
|
+
tokenId: t.string,
|
|
37
|
+
decimalPlaces: t.number,
|
|
38
|
+
}),
|
|
39
|
+
]);
|
|
40
|
+
//# sourceMappingURL=freeze.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freeze.js","sourceRoot":"","sources":["../../../../src/schema/wallet/freeze.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAKd,QAAA,4BAA4B,GAAG,CAAC,CAAC,YAAY,CAAC;IACzD,CAAC,CAAC,IAAI,CAAC;QACL,SAAS,EAAE,CAAC,CAAC,MAAM;QACnB,aAAa,EAAE,CAAC,CAAC,MAAM;KACxB,CAAC;IACF,CAAC,CAAC,OAAO,CAAC;QACR,oBAAoB,EAAE,CAAC,CAAC,MAAM;QAC9B,SAAS,EAAE,CAAC,CAAC,MAAM;QACnB,OAAO,EAAE,CAAC,CAAC,MAAM;QACjB,aAAa,EAAE,CAAC,CAAC,MAAM;KACxB,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -18,4 +18,5 @@ __exportStar(require("./wallet"), exports);
|
|
|
18
18
|
__exportStar(require("./multisigTypeVersion"), exports);
|
|
19
19
|
__exportStar(require("./walletTypes"), exports);
|
|
20
20
|
__exportStar(require("./address"), exports);
|
|
21
|
+
__exportStar(require("./freeze"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schema/wallet/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wDAAsC;AACtC,gDAA8B;AAC9B,4CAA0B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schema/wallet/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wDAAsC;AACtC,gDAA8B;AAC9B,4CAA0B;AAC1B,2CAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getAssetsFromIntent(intent: unknown): string[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAssetsFromIntent = getAssetsFromIntent;
|
|
4
|
+
const Either_1 = require("fp-ts/lib/Either");
|
|
5
|
+
const baseIntent_1 = require("../schema/transactionRequest/intents/baseIntent");
|
|
6
|
+
function getAssetsFromIntent(intent) {
|
|
7
|
+
if (!intent || typeof intent !== "object") {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
const assetStrings = new Set();
|
|
11
|
+
const recipientsDecoded = baseIntent_1.BaseIntentWithRecipients.decode(intent);
|
|
12
|
+
if ((0, Either_1.isRight)(recipientsDecoded)) {
|
|
13
|
+
const data = recipientsDecoded.right;
|
|
14
|
+
for (const recipient of data.recipients) {
|
|
15
|
+
if (recipient.amount?.symbol) {
|
|
16
|
+
assetStrings.add(recipient.amount.symbol);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const tokenDataDecoded = baseIntent_1.BaseIntentWithTokenData.decode(intent);
|
|
21
|
+
if ((0, Either_1.isRight)(tokenDataDecoded)) {
|
|
22
|
+
const data = tokenDataDecoded.right;
|
|
23
|
+
for (const recipient of data.recipients) {
|
|
24
|
+
if (recipient.tokenData?.tokenName) {
|
|
25
|
+
assetStrings.add(recipient.tokenData.tokenName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const tokenNameDecoded = baseIntent_1.BaseIntentWithTokenName.decode(intent);
|
|
30
|
+
if ((0, Either_1.isRight)(tokenNameDecoded)) {
|
|
31
|
+
const data = tokenNameDecoded.right;
|
|
32
|
+
if (data.tokenName) {
|
|
33
|
+
assetStrings.add(data.tokenName);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const amountDecoded = baseIntent_1.BaseIntentWithAmount.decode(intent);
|
|
37
|
+
if ((0, Either_1.isRight)(amountDecoded)) {
|
|
38
|
+
const data = amountDecoded.right;
|
|
39
|
+
if (data.amount?.symbol) {
|
|
40
|
+
assetStrings.add(data.amount.symbol);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return Array.from(assetStrings).sort();
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=getAssetsFromIntent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAssetsFromIntent.js","sourceRoot":"","sources":["../../../src/utils/getAssetsFromIntent.ts"],"names":[],"mappings":";;AAwBA,kDAwDC;AAhFD,6CAA2C;AAC3C,gFAKyD;AAkBzD,SAAgB,mBAAmB,CAAC,MAAe;IACjD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IAKvC,MAAM,iBAAiB,GAAG,qCAAwB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClE,IAAI,IAAA,gBAAO,EAAC,iBAAiB,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC;QACrC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,IAAI,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAC7B,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;IAKD,MAAM,gBAAgB,GAAG,oCAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChE,IAAI,IAAA,gBAAO,EAAC,gBAAgB,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC;QACpC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,IAAI,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC;gBACnC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAKD,MAAM,gBAAgB,GAAG,oCAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChE,IAAI,IAAA,gBAAO,EAAC,gBAAgB,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC;QACpC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAKD,MAAM,aAAa,GAAG,iCAAoB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAI,IAAA,gBAAO,EAAC,aAAa,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC;QACjC,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YACxB,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC;AACzC,CAAC"}
|
package/dist/src/utils/index.js
CHANGED
|
@@ -18,4 +18,5 @@ __exportStar(require("./optional"), exports);
|
|
|
18
18
|
__exportStar(require("./primitives"), exports);
|
|
19
19
|
__exportStar(require("./arrayFromSingle"), exports);
|
|
20
20
|
__exportStar(require("./minMaxArray"), exports);
|
|
21
|
+
__exportStar(require("./getAssetsFromIntent"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,+CAA6B;AAC7B,oDAAkC;AAClC,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,+CAA6B;AAC7B,oDAAkC;AAClC,gDAA8B;AAC9B,wDAAsC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,165 @@
|
|
|
1
1
|
# Transaction Intents
|
|
2
2
|
|
|
3
|
-
This directory contains the intents for the transaction request schema.
|
|
3
|
+
This directory contains the intents for the transaction request schema. Intents represent different types of blockchain operations (payments, staking, token transfers, etc.) with structured, validated data.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Base Intent Patterns
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
and to regenerate the index.ts file.
|
|
7
|
+
To ensure consistency and enable automatic asset extraction, we provide reusable base intent patterns in `baseIntent.ts`:
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
### `BaseIntentWithRecipients`
|
|
11
10
|
|
|
12
|
-
Use
|
|
13
|
-
|
|
11
|
+
Use for intents that send funds to one or more recipients with standard amounts.
|
|
12
|
+
|
|
13
|
+
**When to use**: Payment intents, consolidation intents
|
|
14
|
+
**Provides**: `recipients: Array<RecipientEntry>` with `amount.symbol` extraction
|
|
15
|
+
**Example**: `PaymentIntent`, `AdaPaymentIntent`, `EthPaymentIntent`
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
export const MyPaymentIntent = t.intersection([
|
|
19
|
+
BaseIntent,
|
|
20
|
+
BaseIntentWithRecipients, // ← Provides recipients array
|
|
21
|
+
t.type({
|
|
22
|
+
intentType: intentTypes.payment,
|
|
23
|
+
// ... your specific fields
|
|
24
|
+
}),
|
|
25
|
+
]);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### `BaseIntentWithTokenRecipients`
|
|
29
|
+
|
|
30
|
+
Use for intents that transfer tokens to recipients.
|
|
31
|
+
|
|
32
|
+
**When to use**: Token transfer intents, token consolidation intents
|
|
33
|
+
**Provides**: `recipients: Array<TokenRecipientEntry>` with `tokenData.tokenName` extraction
|
|
34
|
+
**Example**: `TransferTokenIntent`, `EthTransferTokenIntent`
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
export const MyTokenIntent = t.intersection([
|
|
38
|
+
BaseIntent,
|
|
39
|
+
BaseIntentWithTokenRecipients, // ← Provides token recipients
|
|
40
|
+
t.type({
|
|
41
|
+
intentType: intentTypes.transferToken,
|
|
42
|
+
// ... your specific fields
|
|
43
|
+
}),
|
|
44
|
+
]);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### `BaseIntentWithTokenName`
|
|
48
|
+
|
|
49
|
+
Use for intents that reference a token by name directly (not in recipients).
|
|
50
|
+
|
|
51
|
+
**When to use**: Token approval intents, token configuration intents
|
|
52
|
+
**Provides**: `tokenName: string` field with automatic extraction
|
|
53
|
+
**Example**: `TokenApprovalIntent`
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
export const MyTokenApprovalIntent = t.intersection([
|
|
57
|
+
BaseIntent,
|
|
58
|
+
BaseIntentWithTokenName, // ← Provides tokenName field
|
|
59
|
+
t.type({
|
|
60
|
+
intentType: intentTypes.tokenApproval,
|
|
61
|
+
// ... your specific fields
|
|
62
|
+
}),
|
|
63
|
+
]);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `BaseIntentWithAmount`
|
|
67
|
+
|
|
68
|
+
Use for intents with a direct amount field (not in a recipients array).
|
|
69
|
+
|
|
70
|
+
**When to use**: Staking, unstaking, delegation, withdrawal, claim rewards intents
|
|
71
|
+
**Provides**: `amount: Amount` field with `symbol` extraction
|
|
72
|
+
**Example**: `AtomStakeIntent`, `SolStakeIntent`, `BscDelegateIntent`
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
export const MyStakeIntent = t.intersection([
|
|
76
|
+
StakeIntent,
|
|
77
|
+
BaseIntentWithAmount, // ← Provides amount field
|
|
78
|
+
t.type({
|
|
79
|
+
validatorAddress: t.string,
|
|
80
|
+
// ... your specific fields
|
|
81
|
+
}),
|
|
82
|
+
]);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Adding a New Intent
|
|
86
|
+
|
|
87
|
+
When adding a new intent type, follow these steps:
|
|
88
|
+
|
|
89
|
+
### 1. Create Your Intent Schema
|
|
90
|
+
|
|
91
|
+
Create a new file in this directory (e.g., `myChainStakeIntent.ts`):
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import * as t from "io-ts";
|
|
95
|
+
import { StakeIntent } from "./stakeIntent";
|
|
96
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
97
|
+
|
|
98
|
+
export const MyChainStakeIntent = t.intersection([
|
|
99
|
+
StakeIntent,
|
|
100
|
+
BaseIntentWithAmount, // ← Use appropriate base pattern!
|
|
101
|
+
t.type({
|
|
102
|
+
validatorAddress: t.string,
|
|
103
|
+
// ... other required fields
|
|
104
|
+
}),
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
export type MyChainStakeIntent = t.TypeOf<typeof MyChainStakeIntent>;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Important**: Choose the appropriate base pattern(s) based on what asset data your intent contains:
|
|
111
|
+
|
|
112
|
+
- Has `recipients` with amounts? Use `BaseIntentWithRecipients`
|
|
113
|
+
- Has `recipients` with token data? Use `BaseIntentWithTokenRecipients`
|
|
114
|
+
- Has a direct `tokenName` field? Use `BaseIntentWithTokenName`
|
|
115
|
+
- Has a direct `amount` field? Use `BaseIntentWithAmount`
|
|
116
|
+
- No asset data? Just use `BaseIntent`
|
|
117
|
+
|
|
118
|
+
### 2. Export in TransactionIntent Union
|
|
119
|
+
|
|
120
|
+
Add your intent to the union in `intent.ts`:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
export const TransactionIntent = t.union([
|
|
124
|
+
// ... existing intents
|
|
125
|
+
MyChainStakeIntent, // ← Add yours here
|
|
126
|
+
]);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 3. Add Test Coverage
|
|
130
|
+
|
|
131
|
+
**CRITICAL**: Add test data to `test/utils/getAssetsFromIntent.test.ts` in the `INTENT_TEST_REGISTRY`:
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
const INTENT_TEST_REGISTRY = new Map<string, IntentTestCase>([
|
|
135
|
+
// ... existing entries
|
|
136
|
+
[
|
|
137
|
+
"MyChainStakeIntent",
|
|
138
|
+
{
|
|
139
|
+
codec: MyChainStakeIntent,
|
|
140
|
+
data: {
|
|
141
|
+
intentType: "stake",
|
|
142
|
+
stakingRequestId: "test123",
|
|
143
|
+
validatorAddress: "validator_addr",
|
|
144
|
+
amount: { value: "1000000", symbol: "mychain" },
|
|
145
|
+
},
|
|
146
|
+
expectedAssets: ["mychain"], // ← What assets should be extracted
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
]);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Why this is critical**: We have automatic CI protection that reads the `TransactionIntent` union at runtime and verifies:
|
|
153
|
+
|
|
154
|
+
- Every intent has an entry in `INTENT_TEST_REGISTRY`
|
|
155
|
+
- The test data decodes successfully against your schema
|
|
156
|
+
- Asset extraction works correctly
|
|
157
|
+
|
|
158
|
+
**If you don't add test coverage, the CI build will fail!** This ensures the `getAssetsFromIntent` utility remains future-proof.
|
|
159
|
+
|
|
160
|
+
### 4. Regenerate index.ts
|
|
161
|
+
|
|
162
|
+
Export all intents by regenerating the index file:
|
|
14
163
|
|
|
15
164
|
```bash
|
|
16
165
|
# Delete the existing index.ts file if it exists
|
|
@@ -18,7 +167,7 @@ if [ -f src/schema/transactionRequest/intents/index.ts ]; then
|
|
|
18
167
|
rm src/schema/transactionRequest/intents/index.ts
|
|
19
168
|
fi
|
|
20
169
|
|
|
21
|
-
# Loop through each .ts file
|
|
170
|
+
# Loop through each .ts file and append export statements to index.ts
|
|
22
171
|
for file in src/schema/transactionRequest/intents/*.ts; do
|
|
23
172
|
filename=$(basename -- "$file")
|
|
24
173
|
filenameWithoutExt="${filename%.*}"
|
|
@@ -27,3 +176,26 @@ for file in src/schema/transactionRequest/intents/*.ts; do
|
|
|
27
176
|
fi
|
|
28
177
|
done
|
|
29
178
|
```
|
|
179
|
+
|
|
180
|
+
## Asset Extraction
|
|
181
|
+
|
|
182
|
+
The `getAssetsFromIntent` utility automatically extracts asset identifiers from any intent object. It uses the base intent patterns to identify and extract:
|
|
183
|
+
|
|
184
|
+
- **Symbol names** (e.g., 'eth', 'btc', 'ada') from `amount.symbol` fields
|
|
185
|
+
- **Token names** (e.g., 'USDC', 'DAI') from `tokenName` or `tokenData.tokenName` fields
|
|
186
|
+
|
|
187
|
+
**What counts as an "asset"?**
|
|
188
|
+
|
|
189
|
+
- ✅ `symbol` - The currency/coin identifier
|
|
190
|
+
- ✅ `tokenName` - The token identifier
|
|
191
|
+
- ❌ `tokenType`, `tokenContractAddress`, `tokenId` - Technical implementation details
|
|
192
|
+
|
|
193
|
+
By composing your intent with the appropriate base patterns, asset extraction works automatically—no additional code needed!
|
|
194
|
+
|
|
195
|
+
## Best Practices
|
|
196
|
+
|
|
197
|
+
1. **Always use base patterns** instead of manually defining common fields like `amount: Amount` or `recipients: t.array(RecipientEntry)`
|
|
198
|
+
2. **Add test coverage immediately** when creating a new intent—don't wait for CI to fail
|
|
199
|
+
3. **Use minimal test data** in the registry—just enough to satisfy the schema and demonstrate asset extraction
|
|
200
|
+
4. **Keep intent schemas DRY** by leveraging existing base types (`StakeIntent`, `UnstakeIntent`, etc.)
|
|
201
|
+
5. **Document your intent** with JSDoc comments explaining its purpose and required fields
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { Amount } from "./amount";
|
|
3
2
|
import { StakeIntent } from "./stakeIntent";
|
|
3
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @title Apt Stake Intent
|
|
7
7
|
*/
|
|
8
8
|
export const AptStakeIntent = t.intersection([
|
|
9
9
|
StakeIntent,
|
|
10
|
+
BaseIntentWithAmount,
|
|
10
11
|
t.type({
|
|
11
12
|
validatorAddress: t.string,
|
|
12
|
-
amount: Amount,
|
|
13
13
|
}),
|
|
14
14
|
]);
|
|
15
15
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { Amount } from "./amount";
|
|
3
2
|
import { UnstakeIntent } from "./unstakeIntent";
|
|
3
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @title Apt Unstake Intent
|
|
7
7
|
*/
|
|
8
8
|
export const AptUnstakeIntent = t.intersection([
|
|
9
9
|
UnstakeIntent,
|
|
10
|
+
BaseIntentWithAmount,
|
|
10
11
|
t.type({
|
|
11
12
|
validatorAddress: t.string,
|
|
12
|
-
amount: Amount,
|
|
13
13
|
}),
|
|
14
14
|
]);
|
|
15
15
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { Amount } from "./amount";
|
|
3
2
|
import { WithdrawIntent } from "./withdrawIntent";
|
|
3
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @title Apt Withdraw Stake Intent
|
|
7
7
|
*/
|
|
8
8
|
export const AptWithdrawStakeIntent = t.intersection([
|
|
9
9
|
WithdrawIntent,
|
|
10
|
+
BaseIntentWithAmount,
|
|
10
11
|
t.type({
|
|
11
12
|
validatorAddress: t.string,
|
|
12
|
-
amount: Amount,
|
|
13
13
|
}),
|
|
14
14
|
]);
|
|
15
15
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { Amount } from "./amount";
|
|
3
2
|
import { RecipientEntry } from "./recipientEntry";
|
|
4
3
|
import { Optional } from "../../../utils";
|
|
5
4
|
import { StakeIntent } from "./stakeIntent";
|
|
5
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @title Atom Stake Intent
|
|
9
9
|
*/
|
|
10
10
|
export const AtomStakeIntent = t.intersection([
|
|
11
11
|
StakeIntent,
|
|
12
|
+
BaseIntentWithAmount,
|
|
12
13
|
t.type({
|
|
13
14
|
validatorAddress: t.string,
|
|
14
|
-
amount: Amount,
|
|
15
15
|
}),
|
|
16
16
|
t.partial({
|
|
17
17
|
recipients: Optional(t.array(RecipientEntry)),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { Amount } from "./amount";
|
|
3
2
|
import { UnstakeIntent } from "./unstakeIntent";
|
|
3
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
4
4
|
import { RecipientEntry } from "./recipientEntry";
|
|
5
5
|
import { Optional } from "../../../utils";
|
|
6
6
|
|
|
@@ -9,9 +9,9 @@ import { Optional } from "../../../utils";
|
|
|
9
9
|
*/
|
|
10
10
|
export const AtomUnstakeIntent = t.intersection([
|
|
11
11
|
UnstakeIntent,
|
|
12
|
+
BaseIntentWithAmount,
|
|
12
13
|
t.type({
|
|
13
14
|
validatorAddress: t.string,
|
|
14
|
-
amount: Amount,
|
|
15
15
|
}),
|
|
16
16
|
t.partial({
|
|
17
17
|
recipients: Optional(t.array(RecipientEntry)),
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { Amount } from "./amount";
|
|
3
2
|
import { WithdrawIntent } from "./withdrawIntent";
|
|
3
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @title Atom Withdraw Intent
|
|
7
7
|
*/
|
|
8
8
|
export const AtomWithdrawIntent = t.intersection([
|
|
9
9
|
WithdrawIntent,
|
|
10
|
+
BaseIntentWithAmount,
|
|
10
11
|
t.type({
|
|
11
12
|
validatorAddress: t.string,
|
|
12
|
-
amount: Amount,
|
|
13
13
|
}),
|
|
14
14
|
]);
|
|
15
15
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import { IntentType } from "./intentType";
|
|
3
3
|
import { Optional, optionalString } from "../../../utils";
|
|
4
|
+
import { RecipientEntry } from "./recipientEntry";
|
|
5
|
+
import { TokenRecipientEntry } from "./tokenRecipientEntry";
|
|
6
|
+
import { Amount } from "./amount";
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* @title Intent
|
|
@@ -29,3 +32,116 @@ export const BaseIntentWithoutNonce = t.intersection([
|
|
|
29
32
|
]);
|
|
30
33
|
|
|
31
34
|
export type BaseIntentWithoutNonce = t.TypeOf<typeof BaseIntentWithoutNonce>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* ============================================================================
|
|
38
|
+
* REUSABLE SCHEMA FRAGMENTS FOR ASSET-CONTAINING INTENTS
|
|
39
|
+
* ============================================================================
|
|
40
|
+
*
|
|
41
|
+
* These schemas define reusable building blocks that concrete intent schemas
|
|
42
|
+
* can compose with. They serve multiple purposes:
|
|
43
|
+
*
|
|
44
|
+
* 1. **Schema Reuse**: Concrete intents can intersect with these fragments
|
|
45
|
+
* 2. **Pattern Matching**: getAssetsFromIntent utility matches against these
|
|
46
|
+
* 3. **Type Safety**: Ensures consistency across all asset-containing intents
|
|
47
|
+
* 4. **Documentation**: Clearly shows which intents handle which asset types
|
|
48
|
+
*
|
|
49
|
+
* By using the actual RecipientEntry and TokenRecipientEntry types, we ensure
|
|
50
|
+
* these patterns exactly match the structures used in concrete intents.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Schema fragment for intents with standard recipients (payment-like intents)
|
|
55
|
+
*
|
|
56
|
+
* This fragment defines a recipients array using RecipientEntry, which contains
|
|
57
|
+
* address and amount (with value and symbol) fields.
|
|
58
|
+
*
|
|
59
|
+
* Used by:
|
|
60
|
+
* - PaymentIntent (and all variants: AdaPaymentIntent, EthPaymentIntent, etc.)
|
|
61
|
+
* - ConsolidateIntent variants (when they include recipients)
|
|
62
|
+
*
|
|
63
|
+
* Asset extraction: Extracts `symbol` from each recipient's amount
|
|
64
|
+
*/
|
|
65
|
+
export const BaseIntentWithRecipients = t.type({
|
|
66
|
+
recipients: t.array(RecipientEntry),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export type BaseIntentWithRecipients = t.TypeOf<
|
|
70
|
+
typeof BaseIntentWithRecipients
|
|
71
|
+
>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Schema fragment for intents with token recipients
|
|
75
|
+
*
|
|
76
|
+
* This fragment defines a recipients array using TokenRecipientEntry, which
|
|
77
|
+
* extends RecipientEntry with optional tokenData containing token-specific info.
|
|
78
|
+
*
|
|
79
|
+
* Used by:
|
|
80
|
+
* - TransferTokenIntent (and variants: EthTransferTokenIntent, etc.)
|
|
81
|
+
* - ConsolidateTokenIntent (and variants: EthConsolidateTokenIntent, etc.)
|
|
82
|
+
*
|
|
83
|
+
* Asset extraction: Extracts tokenName only (the actual asset identifier)
|
|
84
|
+
* Note: tokenType, tokenContractAddress, tokenId are technical fields, not assets
|
|
85
|
+
* Note: This also matches BaseIntentWithRecipients since TokenRecipientEntry extends RecipientEntry
|
|
86
|
+
*/
|
|
87
|
+
export const BaseIntentWithTokenRecipients = t.type({
|
|
88
|
+
recipients: t.array(TokenRecipientEntry),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export type BaseIntentWithTokenRecipients = t.TypeOf<
|
|
92
|
+
typeof BaseIntentWithTokenRecipients
|
|
93
|
+
>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Pattern for matching token data in recipients
|
|
97
|
+
* Used to extract tokenName (the asset identifier) from token-related intents
|
|
98
|
+
*/
|
|
99
|
+
export const BaseIntentWithTokenData = t.type({
|
|
100
|
+
recipients: t.array(
|
|
101
|
+
t.partial({
|
|
102
|
+
tokenData: t.partial({
|
|
103
|
+
tokenName: t.string,
|
|
104
|
+
}),
|
|
105
|
+
}),
|
|
106
|
+
),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export type BaseIntentWithTokenData = t.TypeOf<typeof BaseIntentWithTokenData>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Schema fragment for intents with direct tokenName field
|
|
113
|
+
*
|
|
114
|
+
* This fragment defines a tokenName field directly on the intent object
|
|
115
|
+
* (not nested in recipients).
|
|
116
|
+
*
|
|
117
|
+
* Used by:
|
|
118
|
+
* - TokenApprovalIntent
|
|
119
|
+
*
|
|
120
|
+
* Asset extraction: Extracts tokenName
|
|
121
|
+
*/
|
|
122
|
+
export const BaseIntentWithTokenName = t.type({
|
|
123
|
+
tokenName: t.string,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export type BaseIntentWithTokenName = t.TypeOf<typeof BaseIntentWithTokenName>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Schema fragment for intents with direct amount field
|
|
130
|
+
*
|
|
131
|
+
* This fragment defines an amount field directly on the intent object
|
|
132
|
+
* (not nested in recipients). Common in staking, claiming, and delegation intents.
|
|
133
|
+
*
|
|
134
|
+
* Used by:
|
|
135
|
+
* - StakeIntent variants (AtomStakeIntent, SolStakeIntent, etc.)
|
|
136
|
+
* - UnstakeIntent variants (AtomUnstakeIntent, etc.)
|
|
137
|
+
* - DelegateIntent variants (BscDelegateIntent, TonDelegateIntent, etc.)
|
|
138
|
+
* - ClaimRewardsIntent variants (AdaStakeClaimRewardsIntent, etc.)
|
|
139
|
+
* - WithdrawIntent variants (AtomWithdrawIntent, CosmosWithdrawIntent, etc.)
|
|
140
|
+
*
|
|
141
|
+
* Asset extraction: Extracts symbol from the amount field
|
|
142
|
+
*/
|
|
143
|
+
export const BaseIntentWithAmount = t.type({
|
|
144
|
+
amount: Amount,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
export type BaseIntentWithAmount = t.TypeOf<typeof BaseIntentWithAmount>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { Amount } from "./amount";
|
|
3
2
|
import { BaseStakeIntent } from "./baseStakeIntent";
|
|
3
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
4
4
|
import { intentTypes } from "./intentType";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -8,10 +8,10 @@ import { intentTypes } from "./intentType";
|
|
|
8
8
|
*/
|
|
9
9
|
export const BscDelegateIntent = t.intersection([
|
|
10
10
|
BaseStakeIntent,
|
|
11
|
+
BaseIntentWithAmount,
|
|
11
12
|
t.type({
|
|
12
13
|
intentType: intentTypes.delegate,
|
|
13
14
|
validatorAddress: t.string,
|
|
14
|
-
amount: Amount,
|
|
15
15
|
}),
|
|
16
16
|
t.partial({
|
|
17
17
|
// Add optional properties here
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { Amount } from "./amount";
|
|
3
2
|
import { BaseStakeIntent } from "./baseStakeIntent";
|
|
3
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
4
4
|
import { intentTypes } from "./intentType";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -8,10 +8,10 @@ import { intentTypes } from "./intentType";
|
|
|
8
8
|
*/
|
|
9
9
|
export const BscUnDelegateIntent = t.intersection([
|
|
10
10
|
BaseStakeIntent,
|
|
11
|
+
BaseIntentWithAmount,
|
|
11
12
|
t.type({
|
|
12
13
|
intentType: intentTypes.undelegate,
|
|
13
14
|
validatorAddress: t.string,
|
|
14
|
-
amount: Amount,
|
|
15
15
|
}),
|
|
16
16
|
t.partial({
|
|
17
17
|
// Add optional properties here
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import { BaseStakeIntentWithCalldata } from "./baseStakeIntentWithCalldata";
|
|
3
|
-
import {
|
|
3
|
+
import { BaseIntentWithAmount } from "./baseIntent";
|
|
4
4
|
import { intentTypes } from "./intentType";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -14,10 +14,10 @@ import { intentTypes } from "./intentType";
|
|
|
14
14
|
*/
|
|
15
15
|
export const CoreDaoDelegateIntent = t.intersection([
|
|
16
16
|
BaseStakeIntentWithCalldata,
|
|
17
|
+
BaseIntentWithAmount,
|
|
17
18
|
t.type({
|
|
18
19
|
intentType: intentTypes.delegate,
|
|
19
20
|
validatorAddress: t.string,
|
|
20
|
-
amount: Amount,
|
|
21
21
|
}),
|
|
22
22
|
]);
|
|
23
23
|
|