@reyaxyz/sdk 0.60.0 → 0.62.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 CHANGED
@@ -6,5 +6,5 @@
6
6
 
7
7
  | Statements | Branches | Functions | Lines |
8
8
  | --------------------------- | ----------------------- | ------------------------- | ----------------- |
9
- | ![Statements](https://img.shields.io/badge/statements-13.28%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-9.33%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-13.84%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-12.58%25-red.svg?style=flat) |
9
+ | ![Statements](https://img.shields.io/badge/statements-12.89%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-9.21%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-13.43%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-12.21%25-red.svg?style=flat) |
10
10
 
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAgF;AAUhF;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,iBAAiB;AACjB,IAAI,iBAAiB,GAAsB,IAAI,iBAAiB,CAC9D,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;AAChE,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB;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","sourcesContent":["import { API_CLIENT_CONFIGS, RestClient, ServiceConfig } from '@reyaxyz/common';\n\nexport type BroadcastTransactionMetadata = {\n accountName?: string;\n};\n\nexport type TxData = {\n to: string;\n data: string;\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\n// Internal state\nlet transactionModule: TransactionModule = new TransactionModule(\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};\n\nexport const getTransactionModuleClient = (): TransactionModule => {\n if (!transactionModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return transactionModule;\n};\n"]}
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: return [4 /*yield*/, (0, exports.bridgeAndDepositPassivePool)(params)];
80
- case 1:
81
- // todo: IR add checkbox impl
82
- return [2 /*return*/, _a.sent()];
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,OAAO,CAAE,OAAO,CAAC,CAAC;gBAKhE,SAAS,GAAG,IAAA,2BAAkB,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;gBAE1D,MAAM,GAAG,IAAA,cAAK,EAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAElD,gBAAgB,GAAG,IAAA,4BAAmB,EAAC;oBAC3C,iBAAiB,EAAE,iBAAiB;oB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getReyaNetworkFromMoneyInOutChainId,\n getTokenInfoByName,\n} from '@reyaxyz/common';\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 // todo: IR add checkbox impl\n return await bridgeAndDepositPassivePool(params);\n};\n"]}
1
+ {"version":3,"file":"bridgeAndDepositPassivePool.js","sourceRoot":"/","sources":["services/lp/bridgeAndDepositPassivePool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAQyB;AACzB,uCAAyD;AACzD,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,OAAO,CAAE,OAAO,CAAC,CAAC;gBAKhE,SAAS,GAAG,IAAA,2BAAkB,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;gBAE1D,MAAM,GAAG,IAAA,cAAK,EAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAElD,gBAAgB,GAAG,IAAA,4BAAmB,EAAC;oBAC3C,iBAAiB,EAAE,iBAAiB;oBACpC,SAAS,EAAE,SAAS,CAAC,IAAI;iBAC1B,CAAC,CAAC;gBAEG,gBAAgB,GAAG,IAAA,8BAAU,EACjC,IAAA,4CAAmC,EAAC,iBAAiB,CAAC,EACtD,gCAAY,CAAC,eAAe,CAC7B,CAAC;gBAEI,KAA4B,IAAA,0CAAiC,EACjE,gBAAgB,EAChB,MAAM,CAAC,UAAU,CAAC,EAClB,gBAAgB,CAAC,OAAO,EACxB,IAAI,EACJ,IAAA,qCAA4B,EAAC;oBAC3B,iBAAiB,EAAE,iBAAiB;iBACrC,CAAC,EACF,MAAM,CAAC,IAAI,CAAC,EAAE,EACd,MAAM,CAAC,YAAY,EACnB,MAAM,EACN,MAAM,CAAC,CAAC,CAAC,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"]}
@@ -42,7 +42,7 @@ var common_1 = require("@reyaxyz/common");
42
42
  var contractAddresses_1 = require("../../utils/contractAddresses");
43
43
  var common_2 = require("@reyaxyz/common");
44
44
  var approveTokenSpending = function (params) { return __awaiter(void 0, void 0, void 0, function () {
45
- var network, chainId, tokenInfo, tokenContract, contractProxyAddress, maxUint256Bn, approvalTransaction, error_1, _a, error_2;
45
+ var network, chainId, tokenInfo, tokenContract, contractProxyAddress, scaledTokenAmount, approvalTransaction, error_1, _a, error_2;
46
46
  var _b;
47
47
  var _c;
48
48
  return __generator(this, function (_d) {
@@ -72,9 +72,9 @@ var approveTokenSpending = function (params) { return __awaiter(void 0, void 0,
72
72
  default:
73
73
  throw new Error('Unexpected approval type in approveTokenSpending');
74
74
  }
75
- maxUint256Bn = BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639935');
75
+ scaledTokenAmount = (0, common_1.scale)(tokenInfo.decimals)(params.amount);
76
76
  return [4 /*yield*/, tokenContract
77
- .approve(contractProxyAddress, maxUint256Bn)
77
+ .approve(contractProxyAddress, scaledTokenAmount)
78
78
  .catch(function (error) {
79
79
  console.warn('Transaction Confirmation Error');
80
80
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"file":"approve.js","sourceRoot":"/","sources":["services/token/approve.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2D;AAC3D,0CAMyB;AACzB,mEAAyE;AACzE,0CAAqD;AAE9C,IAAM,oBAAoB,GAAG,UAClC,MAA0B;;;;;;oBAEV,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,OAAO,GAAG,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;gBAGrC,SAAS,GAAG,IAAA,8BAAqB,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC3D,IAAI,oBAAY,CAAC,MAAM,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,C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AAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;;;gBAI5B,KAAA,0BAAiB,CAAA;;gBACb,qBAAM,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAA;oBAD1C,qBAAM,mBACX,gBAAa,GAAE,SAAgC;wBAC/C,eAAY,GAAE,SAAS,CAAC,OAAO;wBAC/B,iBAAc,GAAE,oBAAoB;wBACpC,UAAO,GAAE,MAAM,CAAC,MAAM;6BACtB,EAAA;oBALF,sBAAO,SAKL,EAAC;;;gBAEH,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;;qBAG5C,sBAAO,CAAC,EAAC;;;KACV,CAAC;AAlEW,QAAA,oBAAoB,wBAkE/B","sourcesContent":["import { ApprovalType, ApproveTokenParams } from './types';\nimport {\n getERC20Allowance,\n getERC20TokenContract,\n getSocketVault,\n GetSocketVaultParams,\n getTokenInfoByAddress,\n} from '@reyaxyz/common';\nimport { ContractType, getAddress } from '../../utils/contractAddresses';\nimport { getTokenInfoByName } from '@reyaxyz/common';\n\nexport const approveTokenSpending = async (\n params: ApproveTokenParams,\n): Promise<number> => {\n const network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\n\n // todo: to be removed once lp form in offchain/UI is fixed\n let tokenInfo = getTokenInfoByAddress(params.tokenAddress);\n if (ApprovalType.BRIDGE && tokenInfo.name === 'RUSD') {\n tokenInfo = getTokenInfoByName('USDC', chainId);\n }\n\n const tokenContract = getERC20TokenContract(tokenInfo.address, params.signer);\n\n let contractProxyAddress;\n switch (params.type) {\n case ApprovalType.DEPOSIT:\n contractProxyAddress = getAddress(chainId, ContractType.CORE_PROXY);\n break;\n case ApprovalType.LP:\n contractProxyAddress = getAddress(\n chainId,\n ContractType.PASSIVE_POOL_PROXY,\n );\n break;\n case ApprovalType.BRIDGE:\n contractProxyAddress = getSocketVault({\n moneyInOutChainId: chainId,\n tokenName: tokenInfo.name,\n } as GetSocketVaultParams);\n break;\n default:\n throw new Error('Unexpected approval type in approveTokenSpending');\n }\n\n // @todo validate if maxAllowance should be passed from UI\n const maxUint256Bn = BigInt(\n '115792089237316195423570985008687907853269984665640564039457584007913129639935',\n );\n\n const approvalTransaction = await tokenContract\n .approve(contractProxyAddress, maxUint256Bn)\n .catch((error) => {\n console.warn('Transaction Confirmation Error');\n console.error(error);\n throw new Error('Transaction Confirmation Error');\n });\n try {\n await approvalTransaction.wait();\n } catch (error) {\n console.warn('Token approval failed');\n throw new Error('Token approval failed');\n }\n\n try {\n return await getERC20Allowance({\n walletAddress: await params.signer.getAddress(),\n tokenAddress: tokenInfo.address,\n spenderAddress: contractProxyAddress,\n subject: params.signer,\n });\n } catch (error) {\n console.warn('Fetching allowance failed');\n }\n\n return 0;\n};\n"]}
1
+ {"version":3,"file":"approve.js","sourceRoot":"/","sources":["services/token/approve.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2D;AAC3D,0CAOyB;AACzB,mEAAyE;AACzE,0CAAqD;AAE9C,IAAM,oBAAoB,GAAG,UAClC,MAA0B;;;;;;oBAEV,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,OAAO,GAAG,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;gBAGrC,SAAS,GAAG,IAAA,8BAAqB,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC3D,IAAI,oBAAY,CAAC,MAAM,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBACrD,SAAS,GAAG,IAAA,2BAAkB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAClD,CAAC;gBAEK,aAAa,GAAG,IAAA,8BAAqB,EAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBAG9E,QAAQ,MAAM,CA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AAE,SAAgC;wBAC/C,eAAY,GAAE,SAAS,CAAC,OAAO;wBAC/B,iBAAc,GAAE,oBAAoB;wBACpC,UAAO,GAAE,MAAM,CAAC,MAAM;6BACtB,EAAA;oBALF,sBAAO,SAKL,EAAC;;;gBAEH,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;;qBAG5C,sBAAO,CAAC,EAAC;;;KACV,CAAC;AA/DW,QAAA,oBAAoB,wBA+D/B","sourcesContent":["import { ApprovalType, ApproveTokenParams } from './types';\nimport {\n getERC20Allowance,\n getERC20TokenContract,\n getSocketVault,\n GetSocketVaultParams,\n getTokenInfoByAddress,\n scale,\n} from '@reyaxyz/common';\nimport { ContractType, getAddress } from '../../utils/contractAddresses';\nimport { getTokenInfoByName } from '@reyaxyz/common';\n\nexport const approveTokenSpending = async (\n params: ApproveTokenParams,\n): Promise<number> => {\n const network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\n\n // todo: to be removed once lp form in offchain/UI is fixed\n let tokenInfo = getTokenInfoByAddress(params.tokenAddress);\n if (ApprovalType.BRIDGE && tokenInfo.name === 'RUSD') {\n tokenInfo = getTokenInfoByName('USDC', chainId);\n }\n\n const tokenContract = getERC20TokenContract(tokenInfo.address, params.signer);\n\n let contractProxyAddress;\n switch (params.type) {\n case ApprovalType.DEPOSIT:\n contractProxyAddress = getAddress(chainId, ContractType.CORE_PROXY);\n break;\n case ApprovalType.LP:\n contractProxyAddress = getAddress(\n chainId,\n ContractType.PASSIVE_POOL_PROXY,\n );\n break;\n case ApprovalType.BRIDGE:\n contractProxyAddress = getSocketVault({\n moneyInOutChainId: chainId,\n tokenName: tokenInfo.name,\n } as GetSocketVaultParams);\n break;\n default:\n throw new Error('Unexpected approval type in approveTokenSpending');\n }\n\n const scaledTokenAmount = scale(tokenInfo.decimals)(params.amount);\n\n const approvalTransaction = await tokenContract\n .approve(contractProxyAddress, scaledTokenAmount)\n .catch((error) => {\n console.warn('Transaction Confirmation Error');\n console.error(error);\n throw new Error('Transaction Confirmation Error');\n });\n try {\n await approvalTransaction.wait();\n } catch (error) {\n console.warn('Token approval failed');\n throw new Error('Token approval failed');\n }\n\n try {\n return await getERC20Allowance({\n walletAddress: await params.signer.getAddress(),\n tokenAddress: tokenInfo.address,\n spenderAddress: contractProxyAddress,\n subject: params.signer,\n });\n } catch (error) {\n console.warn('Fetching allowance failed');\n }\n\n return 0;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/token/types.ts"],"names":[],"mappings":";;;AAGA,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,2CAAE,CAAA;IACF,qDAAO,CAAA;IACP,mDAAM,CAAA;AACR,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport { TokenEntity } from '@reyaxyz/common';\n\nexport enum ApprovalType {\n LP,\n DEPOSIT,\n BRIDGE,\n}\n\nexport type ApproveTokenParams = {\n signer: Signer | JsonRpcSigner;\n tokenAddress: TokenEntity['address'];\n type: ApprovalType;\n};\n\nexport type GetAllowanceParams = {\n signer: Signer | JsonRpcSigner;\n tokenAddress: TokenEntity['address'];\n type: ApprovalType;\n};\n\nexport type GetBalanceByTokenAddressParams = {\n signer: Signer | JsonRpcSigner;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type GetUsdcBalanceParams = {\n signer: Signer | JsonRpcSigner;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/token/types.ts"],"names":[],"mappings":";;;AAGA,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,2CAAE,CAAA;IACF,qDAAO,CAAA;IACP,mDAAM,CAAA;AACR,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport { TokenEntity } from '@reyaxyz/common';\n\nexport enum ApprovalType {\n LP,\n DEPOSIT,\n BRIDGE,\n}\n\nexport type ApproveTokenParams = {\n signer: Signer | JsonRpcSigner;\n tokenAddress: TokenEntity['address'];\n amount: number;\n type: ApprovalType;\n};\n\nexport type GetAllowanceParams = {\n signer: Signer | JsonRpcSigner;\n tokenAddress: TokenEntity['address'];\n type: ApprovalType;\n};\n\nexport type GetBalanceByTokenAddressParams = {\n signer: Signer | JsonRpcSigner;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type GetUsdcBalanceParams = {\n signer: Signer | JsonRpcSigner;\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,EAAsB,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhF,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;AACF,qBAAa,iBAAkB,SAAQ,UAAU;IACzC,kBAAkB,CACtB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,4BAA4B;gBAIX,MAAM;;;CAUpC;AAQD,eAAO,MAAM,YAAY,gBACV,aAAa,CAAC,aAAa,CAAC,KACxC,IAGF,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,iBAI7C,CAAC"}
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":"AAYA,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,CAG1D,CAAC"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"approve.d.ts","sourceRoot":"/","sources":["services/token/approve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAW3D,eAAO,MAAM,oBAAoB,WACvB,kBAAkB,KACzB,QAAQ,MAAM,CAgEhB,CAAC"}
1
+ {"version":3,"file":"approve.d.ts","sourceRoot":"/","sources":["services/token/approve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAY3D,eAAO,MAAM,oBAAoB,WACvB,kBAAkB,KACzB,QAAQ,MAAM,CA6DhB,CAAC"}
@@ -8,6 +8,7 @@ export declare enum ApprovalType {
8
8
  export type ApproveTokenParams = {
9
9
  signer: Signer | JsonRpcSigner;
10
10
  tokenAddress: TokenEntity['address'];
11
+ amount: number;
11
12
  type: ApprovalType;
12
13
  };
13
14
  export type GetAllowanceParams = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/token/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,oBAAY,YAAY;IACtB,EAAE,IAAA;IACF,OAAO,IAAA;IACP,MAAM,IAAA;CACP;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/token/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,oBAAY,YAAY;IACtB,EAAE,IAAA;IACF,OAAO,IAAA;IACP,MAAM,IAAA;CACP;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/sdk",
3
- "version": "0.60.0",
3
+ "version": "0.62.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -34,5 +34,5 @@
34
34
  "ethers": "6.9.0"
35
35
  },
36
36
  "packageManager": "pnpm@8.10.4",
37
- "gitHead": "37b365fbbd9e7af0fe27af9659d69aeff397b322"
37
+ "gitHead": "110e627cd7270acae9a9d96eb97294822cc8748b"
38
38
  }
@@ -1,4 +1,9 @@
1
- import { API_CLIENT_CONFIGS, RestClient, ServiceConfig } from '@reyaxyz/common';
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
- // todo: IR add checkbox impl
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
  };
@@ -5,6 +5,7 @@ import {
5
5
  getSocketVault,
6
6
  GetSocketVaultParams,
7
7
  getTokenInfoByAddress,
8
+ scale,
8
9
  } from '@reyaxyz/common';
9
10
  import { ContractType, getAddress } from '../../utils/contractAddresses';
10
11
  import { getTokenInfoByName } from '@reyaxyz/common';
@@ -44,13 +45,10 @@ export const approveTokenSpending = async (
44
45
  throw new Error('Unexpected approval type in approveTokenSpending');
45
46
  }
46
47
 
47
- // @todo validate if maxAllowance should be passed from UI
48
- const maxUint256Bn = BigInt(
49
- '115792089237316195423570985008687907853269984665640564039457584007913129639935',
50
- );
48
+ const scaledTokenAmount = scale(tokenInfo.decimals)(params.amount);
51
49
 
52
50
  const approvalTransaction = await tokenContract
53
- .approve(contractProxyAddress, maxUint256Bn)
51
+ .approve(contractProxyAddress, scaledTokenAmount)
54
52
  .catch((error) => {
55
53
  console.warn('Transaction Confirmation Error');
56
54
  console.error(error);
@@ -10,6 +10,7 @@ export enum ApprovalType {
10
10
  export type ApproveTokenParams = {
11
11
  signer: Signer | JsonRpcSigner;
12
12
  tokenAddress: TokenEntity['address'];
13
+ amount: number;
13
14
  type: ApprovalType;
14
15
  };
15
16