@reyaxyz/sdk 0.61.0 → 0.63.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/README.md +1 -1
- package/dist/config/index.js +29 -1
- package/dist/config/index.js.map +1 -1
- package/dist/services/lp/bridgeAndDepositPassivePool.js +12 -4
- package/dist/services/lp/bridgeAndDepositPassivePool.js.map +1 -1
- package/dist/types/config/index.d.ts +10 -1
- package/dist/types/config/index.d.ts.map +1 -1
- package/dist/types/services/lp/bridgeAndDepositPassivePool.d.ts.map +1 -1
- package/dist/utils/contractAddresses.js +3 -4
- package/dist/utils/contractAddresses.js.map +1 -1
- package/package.json +3 -3
- package/src/config/index.ts +34 -1
- package/src/services/lp/bridgeAndDepositPassivePool.ts +7 -1
- package/src/utils/contractAddresses.ts +4 -4
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
package/dist/config/index.js
CHANGED
|
@@ -51,7 +51,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.getTransactionModuleClient = exports.configureSDK = exports.TransactionModule = void 0;
|
|
54
|
+
exports.getAlphaTermsModuleClient = exports.getTransactionModuleClient = exports.configureSDK = exports.AlphaTermsModule = exports.TransactionModule = void 0;
|
|
55
55
|
var common_1 = require("@reyaxyz/common");
|
|
56
56
|
var TransactionModule = /** @class */ (function (_super) {
|
|
57
57
|
__extends(TransactionModule, _super);
|
|
@@ -74,12 +74,34 @@ var TransactionModule = /** @class */ (function (_super) {
|
|
|
74
74
|
return TransactionModule;
|
|
75
75
|
}(common_1.RestClient));
|
|
76
76
|
exports.TransactionModule = TransactionModule;
|
|
77
|
+
var AlphaTermsModule = /** @class */ (function (_super) {
|
|
78
|
+
__extends(AlphaTermsModule, _super);
|
|
79
|
+
function AlphaTermsModule() {
|
|
80
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
81
|
+
}
|
|
82
|
+
AlphaTermsModule.prototype.registerAlphaSignature = function (params) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
var formData, uri;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
formData = new FormData();
|
|
87
|
+
formData.append('walletAddress', params.walletAddress);
|
|
88
|
+
formData.append('signedLink', params.link);
|
|
89
|
+
uri = '/api/tos/alpha-signatures';
|
|
90
|
+
return [2 /*return*/, this.post(uri, undefined, formData, undefined)];
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return AlphaTermsModule;
|
|
95
|
+
}(common_1.RestClient));
|
|
96
|
+
exports.AlphaTermsModule = AlphaTermsModule;
|
|
77
97
|
// Internal state
|
|
78
98
|
var transactionModule = new TransactionModule(common_1.API_CLIENT_CONFIGS['test'].apiEndpoint);
|
|
99
|
+
var alphaTermsModule = new AlphaTermsModule(common_1.API_CLIENT_CONFIGS['test'].apiEndpoint);
|
|
79
100
|
// Function to configure the SDK
|
|
80
101
|
var configureSDK = function (environment) {
|
|
81
102
|
var config = common_1.API_CLIENT_CONFIGS[environment] || common_1.API_CLIENT_CONFIGS['test'];
|
|
82
103
|
transactionModule = new TransactionModule(config.apiEndpoint);
|
|
104
|
+
alphaTermsModule = new AlphaTermsModule(config.apiEndpoint);
|
|
83
105
|
};
|
|
84
106
|
exports.configureSDK = configureSDK;
|
|
85
107
|
var getTransactionModuleClient = function () {
|
|
@@ -88,4 +110,10 @@ var getTransactionModuleClient = function () {
|
|
|
88
110
|
return transactionModule;
|
|
89
111
|
};
|
|
90
112
|
exports.getTransactionModuleClient = getTransactionModuleClient;
|
|
113
|
+
var getAlphaTermsModuleClient = function () {
|
|
114
|
+
if (!alphaTermsModule)
|
|
115
|
+
throw new Error('SDK is not configured! Call configureSDK()');
|
|
116
|
+
return alphaTermsModule;
|
|
117
|
+
};
|
|
118
|
+
exports.getAlphaTermsModuleClient = getAlphaTermsModuleClient;
|
|
91
119
|
//# sourceMappingURL=index.js.map
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAKyB;AAgBzB;IAAuC,qCAAU;IAAjD;;IAkBA,CAAC;IAjBO,8CAAkB,GAAxB,UACE,MAAc,EACd,eAAuB,EACvB,QAAsC;;;;gBAGhC,GAAG,GAAG,0BAA0B,CAAC;gBACvC,sBAAO,IAAI,CAAC,IAAI,CACd,GAAG,EACH,EAAE,EACF;wBACE,MAAM,EAAE,MAAM;wBACd,eAAe,iBAAA;wBACf,QAAQ,UAAA;qBACT,CACF,EAAC;;;KACH;IACH,wBAAC;AAAD,CAAC,AAlBD,CAAuC,mBAAU,GAkBhD;AAlBY,8CAAiB;AAoB9B;IAAsC,oCAAU;IAAhD;;IAUA,CAAC;IATO,iDAAsB,GAA5B,UAA6B,MAAsB;;;;gBAE3C,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAChC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;gBACvD,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;gBAErC,GAAG,GAAG,2BAA2B,CAAC;gBACxC,sBAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAC;;;KACvD;IACH,uBAAC;AAAD,CAAC,AAVD,CAAsC,mBAAU,GAU/C;AAVY,4CAAgB;AAY7B,iBAAiB;AACjB,IAAI,iBAAiB,GAAsB,IAAI,iBAAiB,CAC9D,2BAAkB,CAAC,MAAM,CAAC,CAAC,WAAW,CACvC,CAAC;AACF,IAAI,gBAAgB,GAAqB,IAAI,gBAAgB,CAC3D,2BAAkB,CAAC,MAAM,CAAC,CAAC,WAAW,CACvC,CAAC;AAEF,gCAAgC;AACzB,IAAM,YAAY,GAAG,UAC1B,WAAyC;IAEzC,IAAM,MAAM,GAAG,2BAAkB,CAAC,WAAW,CAAC,IAAI,2BAAkB,CAAC,MAAM,CAAC,CAAC;IAC7E,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9D,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC9D,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB;AAEK,IAAM,0BAA0B,GAAG;IACxC,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC;AAEK,IAAM,yBAAyB,GAAG;IACvC,IAAI,CAAC,gBAAgB;QACnB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAJW,QAAA,yBAAyB,6BAIpC","sourcesContent":["import {\n Address,\n API_CLIENT_CONFIGS,\n RestClient,\n ServiceConfig,\n} from '@reyaxyz/common';\n\nexport type BroadcastTransactionMetadata = {\n accountName?: string;\n};\n\nexport type TxData = {\n to: string;\n data: string;\n};\n\ntype AlphaTermsData = {\n walletAddress: Address;\n link: string;\n};\n\nexport class TransactionModule extends RestClient {\n async executeTransaction(\n txData: TxData,\n contractAddress: string,\n metadata: BroadcastTransactionMetadata,\n ) {\n // const uri = `/api/transaction-gelato/executeGelato`;\n const uri = `/api/transaction/execute`; //switch between Gelato and internal relayer\n return this.post<{ txHash: string; accountId?: string }>(\n uri,\n {},\n {\n txData: txData,\n contractAddress,\n metadata,\n },\n );\n }\n}\n\nexport class AlphaTermsModule extends RestClient {\n async registerAlphaSignature(params: AlphaTermsData): Promise<void> {\n // Build formData object.\n const formData = new FormData();\n formData.append('walletAddress', params.walletAddress);\n formData.append('signedLink', params.link);\n\n const uri = '/api/tos/alpha-signatures';\n return this.post(uri, undefined, formData, undefined);\n }\n}\n\n// Internal state\nlet transactionModule: TransactionModule = new TransactionModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\nlet alphaTermsModule: AlphaTermsModule = new AlphaTermsModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\n\n// Function to configure the SDK\nexport const configureSDK = (\n environment: ServiceConfig['environment'],\n): void => {\n const config = API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n transactionModule = new TransactionModule(config.apiEndpoint);\n alphaTermsModule = new AlphaTermsModule(config.apiEndpoint);\n};\n\nexport const getTransactionModuleClient = (): TransactionModule => {\n if (!transactionModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return transactionModule;\n};\n\nexport const getAlphaTermsModuleClient = (): AlphaTermsModule => {\n if (!alphaTermsModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return alphaTermsModule;\n};\n"]}
|
|
@@ -38,6 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.bridgeAndDepositPassivePoolUnderAlphaTerms = exports.bridgeAndDepositPassivePool = void 0;
|
|
40
40
|
var common_1 = require("@reyaxyz/common");
|
|
41
|
+
var config_1 = require("../../config");
|
|
41
42
|
var contractAddresses_1 = require("../../utils/contractAddresses");
|
|
42
43
|
var executeTransaction_1 = require("../executeTransaction");
|
|
43
44
|
var encode_1 = require("./encode");
|
|
@@ -74,12 +75,19 @@ var bridgeAndDepositPassivePool = function (params) { return __awaiter(void 0, v
|
|
|
74
75
|
}); };
|
|
75
76
|
exports.bridgeAndDepositPassivePool = bridgeAndDepositPassivePool;
|
|
76
77
|
var bridgeAndDepositPassivePoolUnderAlphaTerms = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var alphaTermsModule;
|
|
77
79
|
return __generator(this, function (_a) {
|
|
78
80
|
switch (_a.label) {
|
|
79
|
-
case 0:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
case 0:
|
|
82
|
+
alphaTermsModule = (0, config_1.getAlphaTermsModuleClient)();
|
|
83
|
+
return [4 /*yield*/, alphaTermsModule.registerAlphaSignature({
|
|
84
|
+
walletAddress: params.ownerAddress,
|
|
85
|
+
link: params.signedLink,
|
|
86
|
+
})];
|
|
87
|
+
case 1:
|
|
88
|
+
_a.sent();
|
|
89
|
+
return [4 /*yield*/, (0, exports.bridgeAndDepositPassivePool)(params)];
|
|
90
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
83
91
|
}
|
|
84
92
|
});
|
|
85
93
|
}); };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridgeAndDepositPassivePool.js","sourceRoot":"/","sources":["services/lp/bridgeAndDepositPassivePool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAQyB;AACzB,mEAAyE;AACzE,4DAA2D;AAC3D,mCAA6D;AAQtD,IAAM,2BAA2B,GAAG,UACzC,MAAyC;;;;;oBAEzB,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,iBAAiB,GAAsB,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP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EACT,MAAM,CAAC,UAAU,CAAC,EAClB,gBAAgB,CAAC,QAAQ,EACzB,MAAM,CAAC,CAAC,CAAC,CACV,EAfiB,IAAI,cAAA,EAAE,KAAK,WAAA,CAe3B;gBAEa,qBAAM,IAAA,uCAAkB,EACrC,MAAM,CAAC,MAAM,EACb,IAAI,EACJ,KAAK,EACL,iBAAiB,EACjB,IAAA,uBAAc,EAAC;wBACb,iBAAiB,EAAE,iBAAiB;wBACpC,SAAS,EAAE,SAAS,CAAC,IAAI;qBAC1B,CAAC,CACH,EAAA;;gBATK,MAAM,GAAG,SASd;gBAED,sBAAO;wBACL,eAAe,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,IAAI;qBACtC,EAAC;;;KACH,CAAC;AAtDW,QAAA,2BAA2B,+BAsDtC;AAEK,IAAM,0CAA0C,GAAG,UACxD,MAAwD;;;;;gBAElD,gBAAgB,GAAG,IAAA,kCAAyB,GAAE,CAAC;gBACrD,qBAAM,gBAAgB,CAAC,sBAAsB,CAAC;wBAC5C,aAAa,EAAE,MAAM,CAAC,YAAY;wBAClC,IAAI,EAAE,MAAM,CAAC,UAAU;qBACxB,CAAC,EAAA;;gBAHF,SAGE,CAAC;gBAEI,qBAAM,IAAA,mCAA2B,EAAC,MAAM,CAAC,EAAA;oBAAhD,sBAAO,SAAyC,EAAC;;;KAClD,CAAC;AAVW,QAAA,0CAA0C,8CAUrD","sourcesContent":["import {\n getSocketDepositFeesAsBigInt,\n getSocketVault,\n scale,\n MoneyInOutChainId,\n getSocketConnectors,\n getReyaNetworkFromMoneyInOutChainId,\n getTokenInfoByName,\n} from '@reyaxyz/common';\nimport { getAlphaTermsModuleClient } from '../../config';\nimport { ContractType, getAddress } from '../../utils/contractAddresses';\nimport { executeTransaction } from '../executeTransaction';\nimport { encodeBridgeAndDepositPassivePool } from './encode';\nimport {\n BridgeAndDepositPassivePoolParams,\n BridgeAndDepositPassivePoolResult,\n BridgeAndDepositPassivePoolUnderAlphaTermsParams,\n BridgeAndDepositPassivePoolUnderAlphaTermsResult,\n} from './types';\n\nexport const bridgeAndDepositPassivePool = async (\n params: BridgeAndDepositPassivePoolParams,\n): Promise<BridgeAndDepositPassivePoolResult> => {\n const network = await params.signer.provider?.getNetwork();\n const moneyInOutChainId: MoneyInOutChainId = Number(network?.chainId);\n\n // todo: maybe usdc should not be hardcoded\n // it should be the token of the pool, or the underlying token\n // if token is rusd.\n const tokenInfo = getTokenInfoByName('USDC', moneyInOutChainId);\n\n const amount = scale(tokenInfo.decimals)(params.amount);\n\n const socketConnectors = getSocketConnectors({\n moneyInOutChainId: moneyInOutChainId,\n tokenName: tokenInfo.name,\n });\n\n const peripheryAddress = getAddress(\n getReyaNetworkFromMoneyInOutChainId(moneyInOutChainId),\n ContractType.PERIPHERY_PROXY,\n );\n\n const { calldata: data, value } = encodeBridgeAndDepositPassivePool(\n peripheryAddress,\n BigInt('10000000'),\n socketConnectors.deposit,\n '0x',\n getSocketDepositFeesAsBigInt({\n moneyInOutChainId: moneyInOutChainId,\n }),\n params.pool.id,\n params.ownerAddress,\n amount,\n BigInt(0),\n BigInt('10000000'),\n socketConnectors.withdraw,\n BigInt(0),\n );\n\n const result = await executeTransaction(\n params.signer,\n data,\n value,\n moneyInOutChainId,\n getSocketVault({\n moneyInOutChainId: moneyInOutChainId,\n tokenName: tokenInfo.name,\n }),\n );\n\n return {\n transactionHash: result?.hash || null,\n };\n};\n\nexport const bridgeAndDepositPassivePoolUnderAlphaTerms = async (\n params: BridgeAndDepositPassivePoolUnderAlphaTermsParams,\n): Promise<BridgeAndDepositPassivePoolUnderAlphaTermsResult> => {\n const alphaTermsModule = getAlphaTermsModuleClient();\n await alphaTermsModule.registerAlphaSignature({\n walletAddress: params.ownerAddress,\n link: params.signedLink,\n });\n\n return await bridgeAndDepositPassivePool(params);\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RestClient, ServiceConfig } from '@reyaxyz/common';
|
|
1
|
+
import { Address, RestClient, ServiceConfig } from '@reyaxyz/common';
|
|
2
2
|
export type BroadcastTransactionMetadata = {
|
|
3
3
|
accountName?: string;
|
|
4
4
|
};
|
|
@@ -6,12 +6,21 @@ export type TxData = {
|
|
|
6
6
|
to: string;
|
|
7
7
|
data: string;
|
|
8
8
|
};
|
|
9
|
+
type AlphaTermsData = {
|
|
10
|
+
walletAddress: Address;
|
|
11
|
+
link: string;
|
|
12
|
+
};
|
|
9
13
|
export declare class TransactionModule extends RestClient {
|
|
10
14
|
executeTransaction(txData: TxData, contractAddress: string, metadata: BroadcastTransactionMetadata): Promise<{
|
|
11
15
|
txHash: string;
|
|
12
16
|
accountId?: string | undefined;
|
|
13
17
|
}>;
|
|
14
18
|
}
|
|
19
|
+
export declare class AlphaTermsModule extends RestClient {
|
|
20
|
+
registerAlphaSignature(params: AlphaTermsData): Promise<void>;
|
|
21
|
+
}
|
|
15
22
|
export declare const configureSDK: (environment: ServiceConfig['environment']) => void;
|
|
16
23
|
export declare const getTransactionModuleClient: () => TransactionModule;
|
|
24
|
+
export declare const getAlphaTermsModuleClient: () => AlphaTermsModule;
|
|
25
|
+
export {};
|
|
17
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,UAAU,EACV,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,UAAU;IACzC,kBAAkB,CACtB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,4BAA4B;gBAIX,MAAM;;;CAUpC;AAED,qBAAa,gBAAiB,SAAQ,UAAU;IACxC,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CASpE;AAWD,eAAO,MAAM,YAAY,gBACV,aAAa,CAAC,aAAa,CAAC,KACxC,IAIF,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,iBAI7C,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAO,gBAI5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridgeAndDepositPassivePool.d.ts","sourceRoot":"/","sources":["services/lp/bridgeAndDepositPassivePool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bridgeAndDepositPassivePool.d.ts","sourceRoot":"/","sources":["services/lp/bridgeAndDepositPassivePool.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,gDAAgD,EAChD,gDAAgD,EACjD,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,2BAA2B,WAC9B,iCAAiC,KACxC,QAAQ,iCAAiC,CAoD3C,CAAC;AAEF,eAAO,MAAM,0CAA0C,WAC7C,gDAAgD,KACvD,QAAQ,gDAAgD,CAQ1D,CAAC"}
|
|
@@ -16,11 +16,10 @@ var addresses = (_a = {},
|
|
|
16
16
|
_b[ContractType.PASSIVE_POOL_PROXY] = '0x9afc30bed29d636e566fd9d7dd89d51773724be6',
|
|
17
17
|
_b[ContractType.PERIPHERY_PROXY] = '0xa45d0566144956b6012d461ad509dad2bacacaaf',
|
|
18
18
|
_b),
|
|
19
|
-
// TODO: add proper config
|
|
20
19
|
_a[common_1.ReyaChainId.reyaNetwork] = (_c = {},
|
|
21
|
-
_c[ContractType.CORE_PROXY] = '
|
|
22
|
-
_c[ContractType.PASSIVE_POOL_PROXY] = '
|
|
23
|
-
_c[ContractType.PERIPHERY_PROXY] = '
|
|
20
|
+
_c[ContractType.CORE_PROXY] = '0xa763b6a5e09378434406c003dae6487fbbdc1a80',
|
|
21
|
+
_c[ContractType.PASSIVE_POOL_PROXY] = '0xb4b77d6180cc14472a9a7bdff01cc2459368d413',
|
|
22
|
+
_c[ContractType.PERIPHERY_PROXY] = '0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',
|
|
24
23
|
_c),
|
|
25
24
|
_a);
|
|
26
25
|
var getAddress = function (chainId, contractName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractAddresses.js","sourceRoot":"/","sources":["utils/contractAddresses.ts"],"names":[],"mappings":";;;;AACA,+CAA+C;AAC/C,0CAA8C;AAE9C,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,yDAAyC,CAAA;IACzC,mDAAmC,CAAA;AACrC,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAED,IAAM,SAAS;IACb,GAAC,oBAAW,CAAC,UAAU;QACrB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;WAC/C;IACD,
|
|
1
|
+
{"version":3,"file":"contractAddresses.js","sourceRoot":"/","sources":["utils/contractAddresses.ts"],"names":[],"mappings":";;;;AACA,+CAA+C;AAC/C,0CAA8C;AAE9C,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,yDAAyC,CAAA;IACzC,mDAAmC,CAAA;AACrC,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAED,IAAM,SAAS;IACb,GAAC,oBAAW,CAAC,UAAU;QACrB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;WAC/C;IACD,GAAC,oBAAW,CAAC,WAAW;QACtB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;WAC/C;OACF,CAAC;AACK,IAAM,UAAU,GAAG,UACxB,OAAe,EACf,YAA0B;IAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,6CAAsC,UAAU,CAAE,CAAC,CAAC;IACtE,CAAC;IAED,IAAM,gBAAgB,GAAG,SAAS,CAAC,OAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,kCAA2B,YAAY,cAAW,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAhBW,QAAA,UAAU,cAgBrB","sourcesContent":["export type Address = Lowercase<string>;\n// @todo update with proper chainId for mainnet\nimport { ReyaChainId } from '@reyaxyz/common';\n\nexport enum ContractType {\n CORE_PROXY = 'core_proxy',\n PASSIVE_POOL_PROXY = 'passive_pool_proxy',\n PERIPHERY_PROXY = 'periphery_proxy',\n}\n\nconst addresses: Record<ReyaChainId, Record<ContractType, Address>> = {\n [ReyaChainId.reyaCronos]: {\n [ContractType.CORE_PROXY]: '0x20da8f7aa44f858a3a3e3f03ba6ffad039d1eb28',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0x9afc30bed29d636e566fd9d7dd89d51773724be6',\n [ContractType.PERIPHERY_PROXY]:\n '0xa45d0566144956b6012d461ad509dad2bacacaaf',\n },\n [ReyaChainId.reyaNetwork]: {\n [ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0xb4b77d6180cc14472a9a7bdff01cc2459368d413',\n [ContractType.PERIPHERY_PROXY]:\n '0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',\n },\n};\nexport const getAddress = (\n chainId: number,\n contractName: ContractType,\n): Address => {\n const keyChainId = chainId.toString();\n\n if (!Object.keys(addresses).includes(keyChainId)) {\n throw new Error(`Unspecified addresses for chain id ${keyChainId}`);\n }\n\n const networkAddresses = addresses[chainId as ReyaChainId];\n if (!Object.keys(networkAddresses).includes(contractName)) {\n throw new Error(`Unspecified address for ${contractName} contract`);\n }\n\n return networkAddresses[contractName];\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@reyaxyz/common": "0.
|
|
32
|
+
"@reyaxyz/common": "0.66.0",
|
|
33
33
|
"bignumber.js": "^9.1.2",
|
|
34
34
|
"ethers": "6.9.0"
|
|
35
35
|
},
|
|
36
36
|
"packageManager": "pnpm@8.10.4",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "39f5be036cd878a960d47576497d6672bddf113c"
|
|
38
38
|
}
|
package/src/config/index.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Address,
|
|
3
|
+
API_CLIENT_CONFIGS,
|
|
4
|
+
RestClient,
|
|
5
|
+
ServiceConfig,
|
|
6
|
+
} from '@reyaxyz/common';
|
|
2
7
|
|
|
3
8
|
export type BroadcastTransactionMetadata = {
|
|
4
9
|
accountName?: string;
|
|
@@ -8,6 +13,12 @@ export type TxData = {
|
|
|
8
13
|
to: string;
|
|
9
14
|
data: string;
|
|
10
15
|
};
|
|
16
|
+
|
|
17
|
+
type AlphaTermsData = {
|
|
18
|
+
walletAddress: Address;
|
|
19
|
+
link: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
11
22
|
export class TransactionModule extends RestClient {
|
|
12
23
|
async executeTransaction(
|
|
13
24
|
txData: TxData,
|
|
@@ -28,10 +39,25 @@ export class TransactionModule extends RestClient {
|
|
|
28
39
|
}
|
|
29
40
|
}
|
|
30
41
|
|
|
42
|
+
export class AlphaTermsModule extends RestClient {
|
|
43
|
+
async registerAlphaSignature(params: AlphaTermsData): Promise<void> {
|
|
44
|
+
// Build formData object.
|
|
45
|
+
const formData = new FormData();
|
|
46
|
+
formData.append('walletAddress', params.walletAddress);
|
|
47
|
+
formData.append('signedLink', params.link);
|
|
48
|
+
|
|
49
|
+
const uri = '/api/tos/alpha-signatures';
|
|
50
|
+
return this.post(uri, undefined, formData, undefined);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
31
54
|
// Internal state
|
|
32
55
|
let transactionModule: TransactionModule = new TransactionModule(
|
|
33
56
|
API_CLIENT_CONFIGS['test'].apiEndpoint,
|
|
34
57
|
);
|
|
58
|
+
let alphaTermsModule: AlphaTermsModule = new AlphaTermsModule(
|
|
59
|
+
API_CLIENT_CONFIGS['test'].apiEndpoint,
|
|
60
|
+
);
|
|
35
61
|
|
|
36
62
|
// Function to configure the SDK
|
|
37
63
|
export const configureSDK = (
|
|
@@ -39,6 +65,7 @@ export const configureSDK = (
|
|
|
39
65
|
): void => {
|
|
40
66
|
const config = API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];
|
|
41
67
|
transactionModule = new TransactionModule(config.apiEndpoint);
|
|
68
|
+
alphaTermsModule = new AlphaTermsModule(config.apiEndpoint);
|
|
42
69
|
};
|
|
43
70
|
|
|
44
71
|
export const getTransactionModuleClient = (): TransactionModule => {
|
|
@@ -46,3 +73,9 @@ export const getTransactionModuleClient = (): TransactionModule => {
|
|
|
46
73
|
throw new Error('SDK is not configured! Call configureSDK()');
|
|
47
74
|
return transactionModule;
|
|
48
75
|
};
|
|
76
|
+
|
|
77
|
+
export const getAlphaTermsModuleClient = (): AlphaTermsModule => {
|
|
78
|
+
if (!alphaTermsModule)
|
|
79
|
+
throw new Error('SDK is not configured! Call configureSDK()');
|
|
80
|
+
return alphaTermsModule;
|
|
81
|
+
};
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
getReyaNetworkFromMoneyInOutChainId,
|
|
8
8
|
getTokenInfoByName,
|
|
9
9
|
} from '@reyaxyz/common';
|
|
10
|
+
import { getAlphaTermsModuleClient } from '../../config';
|
|
10
11
|
import { ContractType, getAddress } from '../../utils/contractAddresses';
|
|
11
12
|
import { executeTransaction } from '../executeTransaction';
|
|
12
13
|
import { encodeBridgeAndDepositPassivePool } from './encode';
|
|
@@ -76,6 +77,11 @@ export const bridgeAndDepositPassivePool = async (
|
|
|
76
77
|
export const bridgeAndDepositPassivePoolUnderAlphaTerms = async (
|
|
77
78
|
params: BridgeAndDepositPassivePoolUnderAlphaTermsParams,
|
|
78
79
|
): Promise<BridgeAndDepositPassivePoolUnderAlphaTermsResult> => {
|
|
79
|
-
|
|
80
|
+
const alphaTermsModule = getAlphaTermsModuleClient();
|
|
81
|
+
await alphaTermsModule.registerAlphaSignature({
|
|
82
|
+
walletAddress: params.ownerAddress,
|
|
83
|
+
link: params.signedLink,
|
|
84
|
+
});
|
|
85
|
+
|
|
80
86
|
return await bridgeAndDepositPassivePool(params);
|
|
81
87
|
};
|
|
@@ -16,12 +16,12 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
|
|
|
16
16
|
[ContractType.PERIPHERY_PROXY]:
|
|
17
17
|
'0xa45d0566144956b6012d461ad509dad2bacacaaf',
|
|
18
18
|
},
|
|
19
|
-
// TODO: add proper config
|
|
20
19
|
[ReyaChainId.reyaNetwork]: {
|
|
21
|
-
[ContractType.CORE_PROXY]: '
|
|
20
|
+
[ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',
|
|
22
21
|
[ContractType.PASSIVE_POOL_PROXY]:
|
|
23
|
-
'
|
|
24
|
-
[ContractType.PERIPHERY_PROXY]:
|
|
22
|
+
'0xb4b77d6180cc14472a9a7bdff01cc2459368d413',
|
|
23
|
+
[ContractType.PERIPHERY_PROXY]:
|
|
24
|
+
'0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
export const getAddress = (
|