@reyaxyz/sdk 0.153.3 → 0.154.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  | Statements | Branches | Functions | Lines |
8
8
  | --------------------------- | ----------------------- | ------------------------- | ----------------- |
9
- | ![Statements](https://img.shields.io/badge/statements-36.13%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-65.65%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-25.26%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-34.97%25-red.svg?style=flat) |
9
+ | ![Statements](https://img.shields.io/badge/statements-40.52%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-68.3%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-30%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-39.34%25-red.svg?style=flat) |
10
10
 
11
11
  ## Environments
12
12
 
@@ -53,25 +53,33 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.getGeneralRestModuleClient = exports.getTransactionModuleClient = exports.configureSDK = exports.getSdkConfig = exports.GeneralRestModule = exports.TransactionModule = void 0;
55
55
  var common_1 = require("@reyaxyz/common");
56
+ var transaction_operation_1 = require("./transaction-operation");
56
57
  var TransactionModule = /** @class */ (function (_super) {
57
58
  __extends(TransactionModule, _super);
58
59
  function TransactionModule() {
59
60
  return _super !== null && _super.apply(this, arguments) || this;
60
61
  }
61
- TransactionModule.prototype.executeTransaction = function (txData, contractAddress, metadata) {
62
+ TransactionModule.prototype.executeOperation = function (operation, params) {
62
63
  return __awaiter(this, void 0, void 0, function () {
63
- var result;
64
64
  return __generator(this, function (_a) {
65
- switch (_a.label) {
66
- case 0: return [4 /*yield*/, this.post('/api/transaction-gelato/executeReya', {}, {
67
- txData: txData,
68
- contractAddress: contractAddress,
69
- metadata: metadata,
70
- })];
71
- case 1:
72
- result = _a.sent();
73
- return [2 /*return*/, result];
65
+ return [2 /*return*/, this.post("/api/transaction-gelato/".concat(operation), {}, { params: params })];
66
+ });
67
+ });
68
+ };
69
+ /**
70
+ * Compatibility for existing SDK callers: decode locally, send structured
71
+ * operation fields. Metadata no longer controls server-side persistence.
72
+ */
73
+ TransactionModule.prototype.executeTransaction = function (txData, contractAddress, _metadata, chainId) {
74
+ if (chainId === void 0) { chainId = (0, exports.getSdkConfig)().chain; }
75
+ return __awaiter(this, void 0, void 0, function () {
76
+ var _a, operation, request;
77
+ return __generator(this, function (_b) {
78
+ if (txData.to.toLowerCase() !== contractAddress.toLowerCase()) {
79
+ throw new Error('Transaction target mismatch');
74
80
  }
81
+ _a = (0, transaction_operation_1.decodeTransactionOperation)(contractAddress, txData.data, chainId), operation = _a.operation, request = _a.request;
82
+ return [2 /*return*/, this.executeOperation(operation, request.params)];
75
83
  });
76
84
  });
77
85
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAOyB;AAOzB;IAAuC,qCAAU;IAAjD;;IAwCA,CAAC;IAvCO,8CAAkB,GAAxB,UACE,MAAc,EACd,eAAuB,EACvB,QAAsC;;;;;4BAEvB,qBAAM,IAAI,CAAC,IAAI,CAC5B,qCAAqC,EACrC,EAAE,EACF;4BACE,MAAM,EAAE,MAAM;4BACd,eAAe,iBAAA;4BACf,QAAQ,UAAA;yBACT,CACF,EAAA;;wBARK,MAAM,GAAG,SAQd;wBAED,sBAAO,MAAM,EAAC;;;;KACf;IAEK,kDAAsB,GAA5B,UACE,eAAuB,EACvB,eAAuB,EACvB,aAAqB,EACrB,MAAc,EACd,OAAe,EACf,IAAY;;;;gBAEN,GAAG,GAAG,wBAAiB,eAAe,8BAA2B,CAAC;gBACxE,sBAAO,I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ACxC,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC","sourcesContent":["import {\n RestClient,\n ServiceConfig,\n TransactionExecutionMetadata,\n TransactionExecutionOutput,\n CollateralWithHaircut,\n getApiClientConfig,\n} from '@reyaxyz/common';\n\nexport type TxData = {\n to: string;\n data: string;\n};\n\nexport class TransactionModule extends RestClient {\n async executeTransaction(\n txData: TxData,\n contractAddress: string,\n metadata: TransactionExecutionMetadata,\n ): Promise<TransactionExecutionOutput> {\n const result = await this.post<TransactionExecutionOutput>(\n '/api/transaction-gelato/executeReya',\n {},\n {\n txData: txData,\n contractAddress,\n metadata,\n },\n );\n\n return result;\n }\n\n async pushPendingTransaction(\n marginAccountId: number,\n transactionHash: string,\n sourceChainId: number,\n amount: number,\n assetId: string,\n type: string,\n ) {\n const uri = `/api/accounts/${marginAccountId}/push-pending-transaction`;\n return this.post<{ successful: boolean }>(\n uri,\n {},\n {\n tx_hash: transactionHash,\n source_chain_id: sourceChainId,\n amount,\n asset_id: assetId,\n type: type,\n },\n );\n }\n}\n\nexport class GeneralRestModule extends RestClient {\n async getCollateralInfo(): Promise<CollateralWithHaircut[]> {\n return this.get<CollateralWithHaircut[]>(\n `/api/tokens/available-collaterals/excluding-rusd/${false}`,\n );\n }\n}\n\n// Internal state\nlet transactionModule: TransactionModule | undefined;\nlet generalRestModule: GeneralRestModule | undefined;\n\nlet config: ServiceConfig | undefined;\n\nexport const getSdkConfig = (): ServiceConfig => {\n if (!config) throw new Error('SDK is not configured! Call configureSDK()');\n return config;\n};\n\n// Function to configure the SDK\nexport const configureSDK = (\n environment: ServiceConfig['environment'],\n): void => {\n config = getApiClientConfig(environment);\n transactionModule = new TransactionModule(config.apiEndpoint);\n generalRestModule = new GeneralRestModule(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 getGeneralRestModuleClient = (): GeneralRestModule => {\n if (!generalRestModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return generalRestModule;\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CASyB;AACzB,iEAAqE;AAOrE;IAAuC,qCAAU;IAAjD;;IAsDA,CAAC;IArDO,4CAAgB,GAAtB,UACE,SAAY,EACZ,MAAqC;;;gBAErC,sBAAO,IAAI,CAAC,IAAI,CACd,kCAA2B,SAAS,CAAE,EACtC,EAAE,EACF,EAAE,MAAM,QAAA,EAAE,CACX,EAAC;;;KACH;IAED;;;OAGG;IACG,8CAAkB,GAAxB,UACE,MAAc,EACd,eAAuB,EACvB,SAAuC,EACvC,OAA8B;QAA9B,wBAAA,EAAA,UAAU,IAAA,oBAAY,GAAE,CAAC,KAAK;;;;gBAE9B,IAAI,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC,WAAW,EAAE,EAAE,CAAC;oBAC9D,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;gBACjD,CAAC;gBACK,KAAyB,IAAA,kDAA0B,EACvD,eAAe,EACf,MAAM,CAAC,IAAI,EACX,OAAO,CACR,EAJO,SAAS,eAAA,EAAE,OAAO,aAAA,CAIxB;gBACF,sBAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,EAAC;;;KACzD;IAEK,kDAAsB,GAA5B,UACE,eAAuB,EACvB,eAAuB,EACvB,aAAqB,EACrB,MAAc,EACd,OAAe,EACf,IAAY;;;;gBAEN,GAAG,GAAG,wBAAiB,eAAe,8BAA2B,CAAC;gBACxE,sBAAO,IAAI,CAAC,IAAI,CACd,GAAG,EAC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B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC","sourcesContent":["import {\n RestClient,\n ServiceConfig,\n TransactionExecutionMetadata,\n TransactionExecutionOutput,\n CollateralWithHaircut,\n getApiClientConfig,\n TransactionOperation,\n TransactionOperationParams,\n} from '@reyaxyz/common';\nimport { decodeTransactionOperation } from './transaction-operation';\n\nexport type TxData = {\n to: string;\n data: string;\n};\n\nexport class TransactionModule extends RestClient {\n async executeOperation<K extends TransactionOperation>(\n operation: K,\n params: TransactionOperationParams[K],\n ): Promise<TransactionExecutionOutput> {\n return this.post<TransactionExecutionOutput>(\n `/api/transaction-gelato/${operation}`,\n {},\n { params },\n );\n }\n\n /**\n * Compatibility for existing SDK callers: decode locally, send structured\n * operation fields. Metadata no longer controls server-side persistence.\n */\n async executeTransaction(\n txData: TxData,\n contractAddress: string,\n _metadata: TransactionExecutionMetadata,\n chainId = getSdkConfig().chain,\n ): Promise<TransactionExecutionOutput> {\n if (txData.to.toLowerCase() !== contractAddress.toLowerCase()) {\n throw new Error('Transaction target mismatch');\n }\n const { operation, request } = decodeTransactionOperation(\n contractAddress,\n txData.data,\n chainId,\n );\n return this.executeOperation(operation, request.params);\n }\n\n async pushPendingTransaction(\n marginAccountId: number,\n transactionHash: string,\n sourceChainId: number,\n amount: number,\n assetId: string,\n type: string,\n ) {\n const uri = `/api/accounts/${marginAccountId}/push-pending-transaction`;\n return this.post<{ successful: boolean }>(\n uri,\n {},\n {\n tx_hash: transactionHash,\n source_chain_id: sourceChainId,\n amount,\n asset_id: assetId,\n type: type,\n },\n );\n }\n}\n\nexport class GeneralRestModule extends RestClient {\n async getCollateralInfo(): Promise<CollateralWithHaircut[]> {\n return this.get<CollateralWithHaircut[]>(\n `/api/tokens/available-collaterals/excluding-rusd/${false}`,\n );\n }\n}\n\n// Internal state\nlet transactionModule: TransactionModule | undefined;\nlet generalRestModule: GeneralRestModule | undefined;\n\nlet config: ServiceConfig | undefined;\n\nexport const getSdkConfig = (): ServiceConfig => {\n if (!config) throw new Error('SDK is not configured! Call configureSDK()');\n return config;\n};\n\n// Function to configure the SDK\nexport const configureSDK = (\n environment: ServiceConfig['environment'],\n): void => {\n config = getApiClientConfig(environment);\n transactionModule = new TransactionModule(config.apiEndpoint);\n generalRestModule = new GeneralRestModule(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 getGeneralRestModuleClient = (): GeneralRestModule => {\n if (!generalRestModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return generalRestModule;\n};\n"]}
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeTransactionOperation = void 0;
4
+ var ethers_1 = require("ethers");
5
+ var common_1 = require("@reyaxyz/common");
6
+ var core = new ethers_1.Interface(common_1.CoreAbi);
7
+ var periphery = new ethers_1.Interface(common_1.PeripheryAbi);
8
+ var gateway = new ethers_1.Interface(common_1.OrdersGatewayAbi);
9
+ var signature = function (sig) { return ({
10
+ v: Number(sig.v),
11
+ r: sig.r,
12
+ s: sig.s,
13
+ deadline: sig.deadline.toString(),
14
+ }); };
15
+ /** Keeps existing SDK signing APIs while removing raw calldata from HTTP. */
16
+ function decodeTransactionOperation(target, data, chainId) {
17
+ var decoded = decode(target, data, chainId);
18
+ var call = (0, common_1.buildTransactionOperation)(decoded.operation, decoded.request, chainId).call;
19
+ // Never silently change a signed payload, accept trailing bytes, or widen an
20
+ // unsupported execute batch into an operation. There is no legacy fallback.
21
+ if (call.target.toLowerCase() !== target.toLowerCase() ||
22
+ call.callData.toLowerCase() !== data.toLowerCase()) {
23
+ throw new Error('Unsupported transaction operation');
24
+ }
25
+ return decoded;
26
+ }
27
+ exports.decodeTransactionOperation = decodeTransactionOperation;
28
+ function decode(target, data, chainId) {
29
+ var isTarget = function (contract) {
30
+ return target.toLowerCase() === (0, common_1.getAddress)(chainId, contract).toLowerCase();
31
+ };
32
+ if (isTarget(common_1.ContractType.CORE_PROXY)) {
33
+ var tx = core.parseTransaction({ data: data });
34
+ if ((tx === null || tx === void 0 ? void 0 : tx.name) === 'createAccount') {
35
+ return {
36
+ operation: 'create-account',
37
+ request: { params: { owner: tx.args.accountOwner } },
38
+ };
39
+ }
40
+ }
41
+ if (isTarget(common_1.ContractType.ORDERS_GATEWAY_PROXY)) {
42
+ var tx = gateway.parseTransaction({ data: data });
43
+ if ((tx === null || tx === void 0 ? void 0 : tx.name) === 'managePermissionBySig') {
44
+ return {
45
+ operation: tx.args.permissionState
46
+ ? 'enable-api-wallet'
47
+ : 'disable-api-wallet',
48
+ request: {
49
+ params: {
50
+ owner: tx.args.owner,
51
+ apiWallet: tx.args.target,
52
+ sig: signature(tx.args.sig),
53
+ },
54
+ },
55
+ };
56
+ }
57
+ }
58
+ if (isTarget(common_1.ContractType.PERIPHERY_PROXY)) {
59
+ var tx = periphery.parseTransaction({ data: data });
60
+ var p = tx === null || tx === void 0 ? void 0 : tx.args[0];
61
+ switch (tx === null || tx === void 0 ? void 0 : tx.name) {
62
+ case 'transferFromMAToMA':
63
+ return {
64
+ operation: 'transfer',
65
+ request: {
66
+ params: {
67
+ accountId: p.accountId.toString(),
68
+ toAccountId: p.transfer.destAccountId.toString(),
69
+ token: p.transfer.collateral,
70
+ tokenAmount: p.transfer.collateralAmount.toString(),
71
+ sig: signature(p.sig),
72
+ },
73
+ },
74
+ };
75
+ case 'withdrawMA':
76
+ return {
77
+ operation: 'withdraw',
78
+ request: {
79
+ params: {
80
+ accountId: p.accountId.toString(),
81
+ token: p.token,
82
+ tokenAmount: p.tokenAmount.toString(),
83
+ sig: signature(p.sig),
84
+ receiver: p.receiver,
85
+ chainId: p.chainId.toString(),
86
+ socketMsgGasLimit: p.socketMsgGasLimit.toString(),
87
+ },
88
+ },
89
+ };
90
+ case 'withdrawMALZ':
91
+ return {
92
+ operation: 'withdraw-lz',
93
+ request: {
94
+ params: {
95
+ accountId: p.accountId.toString(),
96
+ token: p.token,
97
+ tokenAmount: p.tokenAmount.toString(),
98
+ sig: signature(p.sig),
99
+ receiver: p.receiver,
100
+ dstEid: p.dstEid.toString(),
101
+ },
102
+ },
103
+ };
104
+ case 'depositLiquidityToAccount':
105
+ return {
106
+ operation: 'deposit-pool',
107
+ request: {
108
+ params: {
109
+ accountId: p.accountId.toString(),
110
+ poolId: p.poolId.toString(),
111
+ sharesAmount: p.sharesAmount.toString(),
112
+ sig: signature(p.sig),
113
+ },
114
+ },
115
+ };
116
+ case 'withdrawPassivePool':
117
+ return {
118
+ operation: 'withdraw-pool',
119
+ request: {
120
+ params: {
121
+ owner: p.owner,
122
+ poolId: p.poolId.toString(),
123
+ sharesAmount: p.sharesAmount.toString(),
124
+ minOut: p.minOut.toString(),
125
+ sig: signature(p.sig),
126
+ socketMsgGasLimit: p.socketMsgGasLimit.toString(),
127
+ chainId: p.chainId.toString(),
128
+ receiver: p.receiver,
129
+ },
130
+ },
131
+ };
132
+ case 'execute': {
133
+ if (p.commands.length !== 1)
134
+ break;
135
+ var command = p.commands[0];
136
+ if (Number(command.commandType) !== common_1.CommandType.MANAGE_POOL_STAKE ||
137
+ command.marketId !== BigInt(0) ||
138
+ command.exchangeId !== BigInt(0))
139
+ break;
140
+ var _a = ethers_1.AbiCoder.defaultAbiCoder().decode(['uint8', 'bytes'], command.inputs), direction = _a[0], inputs = _a[1];
141
+ if (direction !== BigInt(0) && direction !== BigInt(1))
142
+ break;
143
+ var _b = ethers_1.AbiCoder.defaultAbiCoder().decode(['uint128', 'uint256', 'uint256'], inputs), poolId = _b[0], amount = _b[1], minimumOut = _b[2];
144
+ return {
145
+ operation: direction === BigInt(0) ? 'stake' : 'unstake',
146
+ request: {
147
+ params: {
148
+ accountId: p.accountId.toString(),
149
+ poolId: poolId.toString(),
150
+ amount: amount.toString(),
151
+ minimumOut: minimumOut.toString(),
152
+ sig: signature(p.sig),
153
+ },
154
+ },
155
+ };
156
+ }
157
+ }
158
+ }
159
+ throw new Error('Unsupported transaction operation');
160
+ }
161
+ //# sourceMappingURL=transaction-operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-operation.js","sourceRoot":"/","sources":["config/transaction-operation.ts"],"names":[],"mappings":";;;AAAA,iCAAqD;AACrD,0CAWyB;AAEzB,IAAM,IAAI,GAAG,IAAI,kBAAS,CAAC,gBAAO,CAAC,CAAC;AACpC,IAAM,SAAS,GAAG,IAAI,kBAAS,CAAC,qBAAY,CAAC,CAAC;AAC9C,IAAM,OAAO,GAAG,IAAI,kBAAS,CAAC,yBAAgB,CAAC,CAAC;AAShD,IAAM,SAAS,GAAG,UAAC,GAAW,IAAoC,OAAA,CAAC;IACjE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAY;IAC3B,CAAC,EAAE,GAAG,CAAC,CAAC;IACR,CAAC,EAAE,GAAG,CAAC,CAAC;IACR,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE;CAClC,CAAC,EALgE,CAKhE,CAAC;AAEH,6EAA6E;AAC7E,SAAgB,0BAA0B,CACxC,MAAc,EACd,IAAY,EACZ,OAAe;IAEf,IAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACtC,IAAA,IAAI,GAAK,IAAA,kCAAyB,EACxC,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,OAAO,EACf,OAAO,CACR,KAJW,CAIV;IACF,6EAA6E;IAC7E,4EAA4E;IAC5E,IACE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,WAAW,EAAE;QAClD,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,EAClD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAA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QAAQ,EAAE;4BACzB,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;4BACjC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;yBACtB;qBACF;iBACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { AbiCoder, Interface, Result } from 'ethers';\nimport {\n buildTransactionOperation,\n CommandType,\n ContractType,\n CoreAbi,\n getAddress,\n OrdersGatewayAbi,\n PeripheryAbi,\n TransactionOperation,\n TransactionOperationParams,\n TransactionOperationSignature,\n} from '@reyaxyz/common';\n\nconst core = new Interface(CoreAbi);\nconst periphery = new Interface(PeripheryAbi);\nconst gateway = new Interface(OrdersGatewayAbi);\n\ntype OperationRequest = {\n [K in TransactionOperation]: {\n operation: K;\n request: { params: TransactionOperationParams[K] };\n };\n}[TransactionOperation];\n\nconst signature = (sig: Result): TransactionOperationSignature => ({\n v: Number(sig.v) as 27 | 28,\n r: sig.r,\n s: sig.s,\n deadline: sig.deadline.toString(),\n});\n\n/** Keeps existing SDK signing APIs while removing raw calldata from HTTP. */\nexport function decodeTransactionOperation(\n target: string,\n data: string,\n chainId: number,\n): OperationRequest {\n const decoded = decode(target, data, chainId);\n const { call } = buildTransactionOperation(\n decoded.operation,\n decoded.request,\n chainId,\n );\n // Never silently change a signed payload, accept trailing bytes, or widen an\n // unsupported execute batch into an operation. There is no legacy fallback.\n if (\n call.target.toLowerCase() !== target.toLowerCase() ||\n call.callData.toLowerCase() !== data.toLowerCase()\n ) {\n throw new Error('Unsupported transaction operation');\n }\n return decoded;\n}\n\nfunction decode(\n target: string,\n data: string,\n chainId: number,\n): OperationRequest {\n const isTarget = (contract: ContractType) =>\n target.toLowerCase() === getAddress(chainId, contract).toLowerCase();\n if (isTarget(ContractType.CORE_PROXY)) {\n const tx = core.parseTransaction({ data });\n if (tx?.name === 'createAccount') {\n return {\n operation: 'create-account',\n request: { params: { owner: tx.args.accountOwner } },\n };\n }\n }\n if (isTarget(ContractType.ORDERS_GATEWAY_PROXY)) {\n const tx = gateway.parseTransaction({ data });\n if (tx?.name === 'managePermissionBySig') {\n return {\n operation: tx.args.permissionState\n ? 'enable-api-wallet'\n : 'disable-api-wallet',\n request: {\n params: {\n owner: tx.args.owner,\n apiWallet: tx.args.target,\n sig: signature(tx.args.sig),\n },\n },\n };\n }\n }\n if (isTarget(ContractType.PERIPHERY_PROXY)) {\n const tx = periphery.parseTransaction({ data });\n const p = tx?.args[0];\n switch (tx?.name) {\n case 'transferFromMAToMA':\n return {\n operation: 'transfer',\n request: {\n params: {\n accountId: p.accountId.toString(),\n toAccountId: p.transfer.destAccountId.toString(),\n token: p.transfer.collateral,\n tokenAmount: p.transfer.collateralAmount.toString(),\n sig: signature(p.sig),\n },\n },\n };\n case 'withdrawMA':\n return {\n operation: 'withdraw',\n request: {\n params: {\n accountId: p.accountId.toString(),\n token: p.token,\n tokenAmount: p.tokenAmount.toString(),\n sig: signature(p.sig),\n receiver: p.receiver,\n chainId: p.chainId.toString(),\n socketMsgGasLimit: p.socketMsgGasLimit.toString(),\n },\n },\n };\n case 'withdrawMALZ':\n return {\n operation: 'withdraw-lz',\n request: {\n params: {\n accountId: p.accountId.toString(),\n token: p.token,\n tokenAmount: p.tokenAmount.toString(),\n sig: signature(p.sig),\n receiver: p.receiver,\n dstEid: p.dstEid.toString(),\n },\n },\n };\n case 'depositLiquidityToAccount':\n return {\n operation: 'deposit-pool',\n request: {\n params: {\n accountId: p.accountId.toString(),\n poolId: p.poolId.toString(),\n sharesAmount: p.sharesAmount.toString(),\n sig: signature(p.sig),\n },\n },\n };\n case 'withdrawPassivePool':\n return {\n operation: 'withdraw-pool',\n request: {\n params: {\n owner: p.owner,\n poolId: p.poolId.toString(),\n sharesAmount: p.sharesAmount.toString(),\n minOut: p.minOut.toString(),\n sig: signature(p.sig),\n socketMsgGasLimit: p.socketMsgGasLimit.toString(),\n chainId: p.chainId.toString(),\n receiver: p.receiver,\n },\n },\n };\n case 'execute': {\n if (p.commands.length !== 1) break;\n const command = p.commands[0];\n if (\n Number(command.commandType) !== CommandType.MANAGE_POOL_STAKE ||\n command.marketId !== BigInt(0) ||\n command.exchangeId !== BigInt(0)\n )\n break;\n const [direction, inputs] = AbiCoder.defaultAbiCoder().decode(\n ['uint8', 'bytes'],\n command.inputs,\n );\n if (direction !== BigInt(0) && direction !== BigInt(1)) break;\n const [poolId, amount, minimumOut] = AbiCoder.defaultAbiCoder().decode(\n ['uint128', 'uint256', 'uint256'],\n inputs,\n );\n return {\n operation: direction === BigInt(0) ? 'stake' : 'unstake',\n request: {\n params: {\n accountId: p.accountId.toString(),\n poolId: poolId.toString(),\n amount: amount.toString(),\n minimumOut: minimumOut.toString(),\n sig: signature(p.sig),\n },\n },\n };\n }\n }\n }\n throw new Error('Unsupported transaction operation');\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/margin-accounts/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport {\n MoneyInOutChainId,\n OwnerMetadataEntity,\n SocketDepositFees,\n TokenEntity,\n} from '@reyaxyz/common';\n\nexport type CreateAccountParams = {\n ownerAddress: string;\n name: string;\n source?: string;\n};\n\nexport type CreateAccountResult = {\n transactionHash: string | null;\n accountId: number | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n};\n\nexport type TransferMarginBetweenAccountsParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce'>;\n fromMarginAccountId: number;\n toMarginAccountId: number;\n tokenAddress: TokenEntity['address'];\n amount: number;\n};\n\nexport type TransferMarginBetweenAccountsResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n};\n\nexport type WithdrawMAAndBridgeParams = {\n signer: Signer | JsonRpcSigner;\n moneyInOutChainId: MoneyInOutChainId;\n owner: Pick<OwnerMetadataEntity, 'address' | 'coreSigNonce'>;\n marginAccountId: number;\n tokenAddress: TokenEntity['address'];\n amount: number;\n // if not provided it has same value as owner.address\n receiverAddress?: Lowercase<string>;\n};\n\nexport type WithdrawMAAndBridgeParamsResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n};\n\nexport type BridgeAndDepositExistingMAParams = {\n signer: Signer | JsonRpcSigner;\n marginAccountId: number;\n tokenAddress: TokenEntity['address'];\n amount: number;\n socketDepositFees: SocketDepositFees['fees'];\n moneyInOutChainId?: MoneyInOutChainId;\n};\n\nexport type BridgeAndDepositExistingMAResult = {\n transactionHash: string | null;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/margin-accounts/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport {\n MoneyInOutChainId,\n OwnerMetadataEntity,\n SocketDepositFees,\n TokenEntity,\n} from '@reyaxyz/common';\n\nexport type CreateAccountParams = {\n ownerAddress: string;\n /** @deprecated Ignored. Set the name through the authenticated account-name API after creation. */\n name?: string;\n /** @deprecated Ignored by the dedicated create-account endpoint. */\n source?: string;\n};\n\nexport type CreateAccountResult = {\n transactionHash: string | null;\n accountId: number | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n};\n\nexport type TransferMarginBetweenAccountsParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce'>;\n fromMarginAccountId: number;\n toMarginAccountId: number;\n tokenAddress: TokenEntity['address'];\n amount: number;\n};\n\nexport type TransferMarginBetweenAccountsResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n};\n\nexport type WithdrawMAAndBridgeParams = {\n signer: Signer | JsonRpcSigner;\n moneyInOutChainId: MoneyInOutChainId;\n owner: Pick<OwnerMetadataEntity, 'address' | 'coreSigNonce'>;\n marginAccountId: number;\n tokenAddress: TokenEntity['address'];\n amount: number;\n // if not provided it has same value as owner.address\n receiverAddress?: Lowercase<string>;\n};\n\nexport type WithdrawMAAndBridgeParamsResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n};\n\nexport type BridgeAndDepositExistingMAParams = {\n signer: Signer | JsonRpcSigner;\n marginAccountId: number;\n tokenAddress: TokenEntity['address'];\n amount: number;\n socketDepositFees: SocketDepositFees['fees'];\n moneyInOutChainId?: MoneyInOutChainId;\n};\n\nexport type BridgeAndDepositExistingMAResult = {\n transactionHash: string | null;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/margin-accounts-v2/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport { Address, OFTMessagingFee } from '@reyaxyz/common';\n\nexport type CreateAccountParamsV2 = {\n ownerAddress: string;\n name: string;\n};\n\nexport type CreateAccountResultV2 = {\n transactionHash: string | null;\n accountId: number | null;\n};\n\nexport type TransferMAParamsV2 = {\n collateralAddress: Address;\n collateralDecimals: number;\n signer: Signer | JsonRpcSigner;\n coreSigNonce: number;\n fromMarginAccountId: number;\n toMarginAccountId: number;\n amount: number;\n};\n\nexport type TransferMAResultV2 = {\n transactionHash: string | null;\n coreSigNonce: number | null;\n};\n\nexport type SocketBridgeAndDepositMAParamsV2 = {\n collateralAddressInReyaPeriphery: Address;\n collateralDecimals: number;\n chainId: number;\n bridgeFee: string;\n vaultAddress: Address;\n connectorAddress: Address;\n msgGasLimit: string;\n signer: Signer | JsonRpcSigner;\n accountId: number;\n amount: number;\n};\n\n/**\n * Whether the pending row was registered with the API.\n *\n * Recording it is best-effort -- the deposit is already on-chain by then, so a\n * failure never fails the deposit -- but the caller is the one with error\n * reporting wired up, so the outcome is returned rather than swallowed. A\n * `false` here means the deposit will not appear as pending until the bridge\n * delivers and the indexer picks it up.\n */\nexport type PendingTransactionPersistence =\n | { status: true }\n | { status: false; reason: string };\n\nexport type SocketBridgeAndDepositMAResultV2 = {\n transactionHash: string | null;\n persistedPendingTransaction: PendingTransactionPersistence;\n};\n\nexport type LzBridgeAndDepositMAParamsV2 = {\n collateralAddress: Address;\n collateralDecimals: number;\n collateralAddressInReyaPeriphery: Address;\n chainId: number;\n dstEid: number;\n bridgeFee: OFTMessagingFee;\n extraOptions: string;\n signer: Signer | JsonRpcSigner;\n marginAccountId: number;\n amount: number;\n};\n\nexport type LzBridgeAndDepositMAResultV2 = {\n transactionHash: string | null;\n};\n\nexport type EstimateFeeLzBridgeAndDepositMAParamsV2 = Pick<\n LzBridgeAndDepositMAParamsV2,\n | 'collateralAddress'\n | 'collateralDecimals'\n | 'collateralAddressInReyaPeriphery'\n | 'chainId'\n | 'dstEid'\n | 'extraOptions'\n> & {\n signer: Signer | JsonRpcSigner;\n};\n\nexport type EstimateFeeSocketBridgeAndDepositMAParamsV2 = Pick<\n SocketBridgeAndDepositMAParamsV2,\n 'vaultAddress' | 'connectorAddress' | 'msgGasLimit' | 'chainId'\n> & {\n signer: Signer | JsonRpcSigner;\n};\n\nexport type WithdrawMAAndSocketBridgeParamsV2 = {\n collateralAddressInReyaCore: Address;\n collateralDecimals: number;\n destinationChainId: number;\n msgGasLimit: string;\n signer: Signer | JsonRpcSigner;\n coreSigNonce: number;\n marginAccountId: number;\n amount: number;\n receiverAddress: Address;\n};\n\nexport type WithdrawMAAndSocketBridgeResultV2 = {\n transactionHash: string | null;\n coreSigNonce: number | null;\n};\n\nexport type WithdrawMAAndLzBridgeParamsV2 = {\n collateralAddressInReyaCore: Address;\n collateralDecimals: number;\n dstEid: number;\n signer: Signer | JsonRpcSigner;\n coreSigNonce: number;\n marginAccountId: number;\n amount: number;\n receiverAddress: Address;\n};\n\nexport type WithdrawMAAndLzBridgeResultV2 = {\n transactionHash: string | null;\n coreSigNonce: number | null;\n};\n\nexport type Erc20ApproveParamsV2 = {\n collateralAddress: Address;\n collateralDecimals: number;\n spenderAddress: Address;\n chainId: number;\n signer: Signer | JsonRpcSigner;\n amount: number;\n};\n\nexport type Erc20ApproveResultV2 = {\n transactionHash: string | null;\n};\n\nexport type WrapEthParamsV2 = {\n signer: Signer | JsonRpcSigner;\n collateralAddress: Address;\n collateralDecimals: number;\n chainId: number;\n amount: number;\n};\n\nexport type WrapEthResultV2 = {\n transactionHash: string | null;\n};\n\nexport type UnwrapEthParamsV2 = {\n signer: Signer | JsonRpcSigner;\n collateralAddress: Address;\n collateralDecimals: number;\n chainId: number;\n amount: number;\n};\n\nexport type UnwrapEthResultV2 = {\n transactionHash: string | null;\n};\n\nexport type Erc20GetAllowanceParamsV2 = {\n signer: Signer | JsonRpcSigner;\n collateralAddress: Address;\n collateralDecimals: number;\n walletAddress: Address;\n spenderAddress: Address;\n chainId: number;\n};\n\nexport type Erc20GetAllowanceResultV2 = {\n allowance: number;\n};\n\nexport type Erc20GetBalanceParamsV2 = {\n signer: Signer | JsonRpcSigner;\n collateralAddress: Address;\n collateralDecimals: number;\n chainId: number;\n walletAddress: Address;\n};\n\nexport type Erc20GetBalanceResultV2 = {\n balance: number;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/margin-accounts-v2/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport { Address, OFTMessagingFee } from '@reyaxyz/common';\n\nexport type CreateAccountParamsV2 = {\n ownerAddress: string;\n /** @deprecated Ignored. Set the name through the authenticated account-name API after creation. */\n name?: string;\n};\n\nexport type CreateAccountResultV2 = {\n transactionHash: string | null;\n accountId: number | null;\n};\n\nexport type TransferMAParamsV2 = {\n collateralAddress: Address;\n collateralDecimals: number;\n signer: Signer | JsonRpcSigner;\n coreSigNonce: number;\n fromMarginAccountId: number;\n toMarginAccountId: number;\n amount: number;\n};\n\nexport type TransferMAResultV2 = {\n transactionHash: string | null;\n coreSigNonce: number | null;\n};\n\nexport type SocketBridgeAndDepositMAParamsV2 = {\n collateralAddressInReyaPeriphery: Address;\n collateralDecimals: number;\n chainId: number;\n bridgeFee: string;\n vaultAddress: Address;\n connectorAddress: Address;\n msgGasLimit: string;\n signer: Signer | JsonRpcSigner;\n accountId: number;\n amount: number;\n};\n\n/**\n * Whether the pending row was registered with the API.\n *\n * Recording it is best-effort -- the deposit is already on-chain by then, so a\n * failure never fails the deposit -- but the caller is the one with error\n * reporting wired up, so the outcome is returned rather than swallowed. A\n * `false` here means the deposit will not appear as pending until the bridge\n * delivers and the indexer picks it up.\n */\nexport type PendingTransactionPersistence =\n | { status: true }\n | { status: false; reason: string };\n\nexport type SocketBridgeAndDepositMAResultV2 = {\n transactionHash: string | null;\n persistedPendingTransaction: PendingTransactionPersistence;\n};\n\nexport type LzBridgeAndDepositMAParamsV2 = {\n collateralAddress: Address;\n collateralDecimals: number;\n collateralAddressInReyaPeriphery: Address;\n chainId: number;\n dstEid: number;\n bridgeFee: OFTMessagingFee;\n extraOptions: string;\n signer: Signer | JsonRpcSigner;\n marginAccountId: number;\n amount: number;\n};\n\nexport type LzBridgeAndDepositMAResultV2 = {\n transactionHash: string | null;\n};\n\nexport type EstimateFeeLzBridgeAndDepositMAParamsV2 = Pick<\n LzBridgeAndDepositMAParamsV2,\n | 'collateralAddress'\n | 'collateralDecimals'\n | 'collateralAddressInReyaPeriphery'\n | 'chainId'\n | 'dstEid'\n | 'extraOptions'\n> & {\n signer: Signer | JsonRpcSigner;\n};\n\nexport type EstimateFeeSocketBridgeAndDepositMAParamsV2 = Pick<\n SocketBridgeAndDepositMAParamsV2,\n 'vaultAddress' | 'connectorAddress' | 'msgGasLimit' | 'chainId'\n> & {\n signer: Signer | JsonRpcSigner;\n};\n\nexport type WithdrawMAAndSocketBridgeParamsV2 = {\n collateralAddressInReyaCore: Address;\n collateralDecimals: number;\n destinationChainId: number;\n msgGasLimit: string;\n signer: Signer | JsonRpcSigner;\n coreSigNonce: number;\n marginAccountId: number;\n amount: number;\n receiverAddress: Address;\n};\n\nexport type WithdrawMAAndSocketBridgeResultV2 = {\n transactionHash: string | null;\n coreSigNonce: number | null;\n};\n\nexport type WithdrawMAAndLzBridgeParamsV2 = {\n collateralAddressInReyaCore: Address;\n collateralDecimals: number;\n dstEid: number;\n signer: Signer | JsonRpcSigner;\n coreSigNonce: number;\n marginAccountId: number;\n amount: number;\n receiverAddress: Address;\n};\n\nexport type WithdrawMAAndLzBridgeResultV2 = {\n transactionHash: string | null;\n coreSigNonce: number | null;\n};\n\nexport type Erc20ApproveParamsV2 = {\n collateralAddress: Address;\n collateralDecimals: number;\n spenderAddress: Address;\n chainId: number;\n signer: Signer | JsonRpcSigner;\n amount: number;\n};\n\nexport type Erc20ApproveResultV2 = {\n transactionHash: string | null;\n};\n\nexport type WrapEthParamsV2 = {\n signer: Signer | JsonRpcSigner;\n collateralAddress: Address;\n collateralDecimals: number;\n chainId: number;\n amount: number;\n};\n\nexport type WrapEthResultV2 = {\n transactionHash: string | null;\n};\n\nexport type UnwrapEthParamsV2 = {\n signer: Signer | JsonRpcSigner;\n collateralAddress: Address;\n collateralDecimals: number;\n chainId: number;\n amount: number;\n};\n\nexport type UnwrapEthResultV2 = {\n transactionHash: string | null;\n};\n\nexport type Erc20GetAllowanceParamsV2 = {\n signer: Signer | JsonRpcSigner;\n collateralAddress: Address;\n collateralDecimals: number;\n walletAddress: Address;\n spenderAddress: Address;\n chainId: number;\n};\n\nexport type Erc20GetAllowanceResultV2 = {\n allowance: number;\n};\n\nexport type Erc20GetBalanceParamsV2 = {\n signer: Signer | JsonRpcSigner;\n collateralAddress: Address;\n collateralDecimals: number;\n chainId: number;\n walletAddress: Address;\n};\n\nexport type Erc20GetBalanceResultV2 = {\n balance: number;\n};\n"]}
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -52,7 +41,7 @@ var common_1 = require("@reyaxyz/common");
52
41
  var config_1 = require("../config");
53
42
  function signAndBroadcastTransaction(data, chainId, targetContract, metadata) {
54
43
  return __awaiter(this, void 0, void 0, function () {
55
- var contractAddress, transactionExecutionOutput, transactionModuleClient, metadataWithTimestamp, error_1, stringifiedError;
44
+ var contractAddress, transactionExecutionOutput, transactionModuleClient, error_1, stringifiedError;
56
45
  return __generator(this, function (_a) {
57
46
  switch (_a.label) {
58
47
  case 0:
@@ -63,8 +52,7 @@ function signAndBroadcastTransaction(data, chainId, targetContract, metadata) {
63
52
  case 1:
64
53
  _a.trys.push([1, 3, , 4]);
65
54
  transactionModuleClient = (0, config_1.getTransactionModuleClient)();
66
- metadataWithTimestamp = __assign(__assign({}, metadata), { clientSentTimestamp: Date.now(), clientTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone });
67
- return [4 /*yield*/, transactionModuleClient.executeTransaction({ to: contractAddress, data: data }, contractAddress, metadataWithTimestamp)];
55
+ return [4 /*yield*/, transactionModuleClient.executeTransaction({ to: contractAddress, data: data }, contractAddress, metadata, chainId)];
68
56
  case 2:
69
57
  transactionExecutionOutput =
70
58
  _a.sent();
@@ -1 +1 @@
1
- {"version":3,"file":"signAndBroadcastTransaction.js","sourceRoot":"/","sources":["services/signAndBroadcastTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAMyB;AACzB,oCAAuD;AAEvD,SAAsB,2BAA2B,CAC/C,IAAY,EACZ,OAAe,EACf,cAAqC,EACrC,QAAsC;;;;;;oBAEhC,eAAe,GAAG,MAAM,CA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import {\n ContractType,\n getAddress,\n stringifyObject,\n TransactionExecutionMetadata,\n TransactionExecutionOutput,\n} from '@reyaxyz/common';\nimport { getTransactionModuleClient } from '../config';\n\nexport async function signAndBroadcastTransaction(\n data: string,\n chainId: number,\n targetContract: ContractType | string,\n metadata: TransactionExecutionMetadata,\n): Promise<TransactionExecutionOutput> {\n const contractAddress = Object.values(ContractType).includes(\n targetContract as ContractType,\n )\n ? getAddress(chainId, targetContract as ContractType)\n : targetContract;\n\n let transactionExecutionOutput: TransactionExecutionOutput;\n try {\n const transactionModuleClient = getTransactionModuleClient();\n\n // Add client-side timestamp and timezone to measure latency and location\n const metadataWithTimestamp: TransactionExecutionMetadata = {\n ...metadata,\n clientSentTimestamp: Date.now(),\n clientTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n };\n\n transactionExecutionOutput =\n await transactionModuleClient.executeTransaction(\n { to: contractAddress, data: data },\n contractAddress,\n metadataWithTimestamp,\n );\n } catch (error) {\n const stringifiedError = stringifyObject(error);\n\n console.error(\n `Error broadcasting transaction to API: ${data} ${stringifiedError}`,\n );\n\n throw new Error('Transaction Execution Error');\n }\n\n if (transactionExecutionOutput.errorMessage) {\n console.error(\n `Error forwarded from the API: ${data} ${transactionExecutionOutput.errorMessage}`,\n );\n\n throw new Error(transactionExecutionOutput.errorMessage);\n }\n\n if (!transactionExecutionOutput.txHash) {\n console.error(\n `Error receiving transaction hash from API: ${data} ${stringifyObject(\n transactionExecutionOutput,\n )}`,\n );\n\n throw new Error('API response does not include transaction hash');\n }\n\n return transactionExecutionOutput;\n}\n"]}
1
+ {"version":3,"file":"signAndBroadcastTransaction.js","sourceRoot":"/","sources":["services/signAndBroadcastTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAMyB;AACzB,oCAAuD;AAEvD,SAAsB,2BAA2B,CAC/C,IAAY,EACZ,OAAe,EACf,cAAqC,EACrC,QAAsC;;;;;;oBAEhC,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAY,CAAC,CAAC,QAAQ,CAC1D,cAA8B,CAC/B;wBACC,CAAC,CAAC,IAAA,mBAAU,EAAC,OAAO,EAAE,cAA8B,CAAC;wBACrD,CAAC,CAAC,cAAc,CAAC;;;;oBAIX,uBAAuB,GAAG,IAAA,mCAA0B,GAAE,CAAC;oBAG3D,qBAAM,uBAAuB,CAAC,kBAAkB,CAC9C,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,EACnC,eAAe,EACf,QAAQ,EACR,OAAO,CACR,EAAA;;oBANH,0BAA0B;wBACxB,SAKC,CAAC;;;;oBAEE,gBAAgB,GAAG,IAAA,wBAAe,EAAC,OAAK,CAAC,CAAC;oBAEhD,OAAO,CAAC,KAAK,CACX,iDAA0C,IAAI,cAAI,gBAAgB,CAAE,CACrE,CAAC;oBAEF,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;;oBAGjD,IAAI,0BAA0B,CAAC,YAAY,EAAE,CAAC;wBAC5C,OAAO,CAAC,KAAK,CACX,wCAAiC,IAAI,cAAI,0BAA0B,CAAC,YAAY,CAAE,CACnF,CAAC;wBAEF,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,YAAY,CAAC,CAAC;oBAC3D,CAAC;oBAED,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,CAAC;wBACvC,OAAO,CAAC,KAAK,CACX,qDAA8C,IAAI,cAAI,IAAA,wBAAe,EACnE,0BAA0B,CAC3B,CAAE,CACJ,CAAC;wBAEF,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;oBACpE,CAAC;oBAED,sBAAO,0BAA0B,EAAC;;;;CACnC;AApDD,kEAoDC","sourcesContent":["import {\n ContractType,\n getAddress,\n stringifyObject,\n TransactionExecutionMetadata,\n TransactionExecutionOutput,\n} from '@reyaxyz/common';\nimport { getTransactionModuleClient } from '../config';\n\nexport async function signAndBroadcastTransaction(\n data: string,\n chainId: number,\n targetContract: ContractType | string,\n metadata: TransactionExecutionMetadata,\n): Promise<TransactionExecutionOutput> {\n const contractAddress = Object.values(ContractType).includes(\n targetContract as ContractType,\n )\n ? getAddress(chainId, targetContract as ContractType)\n : targetContract;\n\n let transactionExecutionOutput: TransactionExecutionOutput;\n try {\n const transactionModuleClient = getTransactionModuleClient();\n\n transactionExecutionOutput =\n await transactionModuleClient.executeTransaction(\n { to: contractAddress, data: data },\n contractAddress,\n metadata,\n chainId,\n );\n } catch (error) {\n const stringifiedError = stringifyObject(error);\n\n console.error(\n `Error broadcasting transaction to API: ${data} ${stringifiedError}`,\n );\n\n throw new Error('Transaction Execution Error');\n }\n\n if (transactionExecutionOutput.errorMessage) {\n console.error(\n `Error forwarded from the API: ${data} ${transactionExecutionOutput.errorMessage}`,\n );\n\n throw new Error(transactionExecutionOutput.errorMessage);\n }\n\n if (!transactionExecutionOutput.txHash) {\n console.error(\n `Error receiving transaction hash from API: ${data} ${stringifyObject(\n transactionExecutionOutput,\n )}`,\n );\n\n throw new Error('API response does not include transaction hash');\n }\n\n return transactionExecutionOutput;\n}\n"]}
@@ -1,10 +1,15 @@
1
- import { RestClient, ServiceConfig, TransactionExecutionMetadata, TransactionExecutionOutput, CollateralWithHaircut } from '@reyaxyz/common';
1
+ import { RestClient, ServiceConfig, TransactionExecutionMetadata, TransactionExecutionOutput, CollateralWithHaircut, TransactionOperation, TransactionOperationParams } from '@reyaxyz/common';
2
2
  export type TxData = {
3
3
  to: string;
4
4
  data: string;
5
5
  };
6
6
  export declare class TransactionModule extends RestClient {
7
- executeTransaction(txData: TxData, contractAddress: string, metadata: TransactionExecutionMetadata): Promise<TransactionExecutionOutput>;
7
+ executeOperation<K extends TransactionOperation>(operation: K, params: TransactionOperationParams[K]): Promise<TransactionExecutionOutput>;
8
+ /**
9
+ * Compatibility for existing SDK callers: decode locally, send structured
10
+ * operation fields. Metadata no longer controls server-side persistence.
11
+ */
12
+ executeTransaction(txData: TxData, contractAddress: string, _metadata: TransactionExecutionMetadata, chainId?: import("@reyaxyz/common").ReyaChainId): Promise<TransactionExecutionOutput>;
8
13
  pushPendingTransaction(marginAccountId: number, transactionHash: string, sourceChainId: number, amount: number, assetId: string, type: string): Promise<{
9
14
  successful: boolean;
10
15
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,EAEtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,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,GACrC,OAAO,CAAC,0BAA0B,CAAC;IAchC,sBAAsB,CAC1B,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM;oBAGmB,OAAO;;CAYzC;AAED,qBAAa,iBAAkB,SAAQ,UAAU;IACzC,iBAAiB,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;CAK5D;AAQD,eAAO,MAAM,YAAY,QAAO,aAG/B,CAAC;AAGF,eAAO,MAAM,YAAY,gBACV,aAAa,CAAC,aAAa,CAAC,KACxC,IAIF,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,iBAI7C,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,UAAU,EACV,aAAa,EACb,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,EAErB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,iBAAiB,CAAC;AAGzB,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,UAAU;IACzC,gBAAgB,CAAC,CAAC,SAAS,oBAAoB,EACnD,SAAS,EAAE,CAAC,EACZ,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC,GACpC,OAAO,CAAC,0BAA0B,CAAC;IAQtC;;;OAGG;IACG,kBAAkB,CACtB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,4BAA4B,EACvC,OAAO,wCAAuB,GAC7B,OAAO,CAAC,0BAA0B,CAAC;IAYhC,sBAAsB,CAC1B,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM;oBAGmB,OAAO;;CAYzC;AAED,qBAAa,iBAAkB,SAAQ,UAAU;IACzC,iBAAiB,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;CAK5D;AAQD,eAAO,MAAM,YAAY,QAAO,aAG/B,CAAC;AAGF,eAAO,MAAM,YAAY,gBACV,aAAa,CAAC,aAAa,CAAC,KACxC,IAIF,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,iBAI7C,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,iBAI7C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { TransactionOperation, TransactionOperationParams } from '@reyaxyz/common';
2
+ type OperationRequest = {
3
+ [K in TransactionOperation]: {
4
+ operation: K;
5
+ request: {
6
+ params: TransactionOperationParams[K];
7
+ };
8
+ };
9
+ }[TransactionOperation];
10
+ /** Keeps existing SDK signing APIs while removing raw calldata from HTTP. */
11
+ export declare function decodeTransactionOperation(target: string, data: string, chainId: number): OperationRequest;
12
+ export {};
13
+ //# sourceMappingURL=transaction-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-operation.d.ts","sourceRoot":"/","sources":["config/transaction-operation.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,oBAAoB,EACpB,0BAA0B,EAE3B,MAAM,iBAAiB,CAAC;AAMzB,KAAK,gBAAgB,GAAG;KACrB,CAAC,IAAI,oBAAoB,GAAG;QAC3B,SAAS,EAAE,CAAC,CAAC;QACb,OAAO,EAAE;YAAE,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAA;SAAE,CAAC;KACpD;CACF,CAAC,oBAAoB,CAAC,CAAC;AASxB,6EAA6E;AAC7E,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,gBAAgB,CAgBlB"}
@@ -2,7 +2,9 @@ import { JsonRpcSigner, Signer } from 'ethers';
2
2
  import { MoneyInOutChainId, OwnerMetadataEntity, SocketDepositFees, TokenEntity } from '@reyaxyz/common';
3
3
  export type CreateAccountParams = {
4
4
  ownerAddress: string;
5
- name: string;
5
+ /** @deprecated Ignored. Set the name through the authenticated account-name API after creation. */
6
+ name?: string;
7
+ /** @deprecated Ignored by the dedicated create-account endpoint. */
6
8
  source?: string;
7
9
  };
8
10
  export type CreateAccountResult = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/margin-accounts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,M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,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;IAChD,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,EAAE,mBAAmB,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,cAAc,CAAC,CAAC;IAC7D,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IAEf,eAAe,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,EAAE,mBAAmB,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC7C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC"}
@@ -2,7 +2,8 @@ import { JsonRpcSigner, Signer } from 'ethers';
2
2
  import { Address, OFTMessagingFee } from '@reyaxyz/common';
3
3
  export type CreateAccountParamsV2 = {
4
4
  ownerAddress: string;
5
- name: string;
5
+ /** @deprecated Ignored. Set the name through the authenticated account-name API after creation. */
6
+ name?: string;
6
7
  };
7
8
  export type CreateAccountResultV2 = {
8
9
  transactionHash: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/margin-accounts-v2/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,gCAAgC,EAAE,OAAO,CAAC;IAC1C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,aAAa,C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B,EAC3B,MAAM,iBAAiB,CAAC;AAGzB,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,YAAY,GAAG,MAAM,EACrC,QAAQ,EAAE,4BAA4B,GACrC,OAAO,CAAC,0BAA0B,CAAC,CAqDrC"}
1
+ {"version":3,"file":"signAndBroadcastTransaction.d.ts","sourceRoot":"/","sources":["services/signAndBroadcastTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGZ,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,iBAAiB,CAAC;AAGzB,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,YAAY,GAAG,MAAM,EACrC,QAAQ,EAAE,4BAA4B,GACrC,OAAO,CAAC,0BAA0B,CAAC,CA+CrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/sdk",
3
- "version": "0.153.3",
3
+ "version": "0.154.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -30,10 +30,10 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@reyaxyz/api-v2-sdk": "0.315.0",
33
- "@reyaxyz/common": "0.372.0",
33
+ "@reyaxyz/common": "0.373.1",
34
34
  "axios": "1.20.0",
35
35
  "bignumber.js": "9.1.2",
36
36
  "ethers": "6.17.0"
37
37
  },
38
- "gitHead": "cd2b35cf3089435fee2bafdeab9ae6d8e42ca506"
38
+ "gitHead": "c4733b7a18ca9e87db1d10e750da92340d59a384"
39
39
  }
@@ -5,7 +5,10 @@ import {
5
5
  TransactionExecutionOutput,
6
6
  CollateralWithHaircut,
7
7
  getApiClientConfig,
8
+ TransactionOperation,
9
+ TransactionOperationParams,
8
10
  } from '@reyaxyz/common';
11
+ import { decodeTransactionOperation } from './transaction-operation';
9
12
 
10
13
  export type TxData = {
11
14
  to: string;
@@ -13,22 +16,36 @@ export type TxData = {
13
16
  };
14
17
 
15
18
  export class TransactionModule extends RestClient {
19
+ async executeOperation<K extends TransactionOperation>(
20
+ operation: K,
21
+ params: TransactionOperationParams[K],
22
+ ): Promise<TransactionExecutionOutput> {
23
+ return this.post<TransactionExecutionOutput>(
24
+ `/api/transaction-gelato/${operation}`,
25
+ {},
26
+ { params },
27
+ );
28
+ }
29
+
30
+ /**
31
+ * Compatibility for existing SDK callers: decode locally, send structured
32
+ * operation fields. Metadata no longer controls server-side persistence.
33
+ */
16
34
  async executeTransaction(
17
35
  txData: TxData,
18
36
  contractAddress: string,
19
- metadata: TransactionExecutionMetadata,
37
+ _metadata: TransactionExecutionMetadata,
38
+ chainId = getSdkConfig().chain,
20
39
  ): Promise<TransactionExecutionOutput> {
21
- const result = await this.post<TransactionExecutionOutput>(
22
- '/api/transaction-gelato/executeReya',
23
- {},
24
- {
25
- txData: txData,
26
- contractAddress,
27
- metadata,
28
- },
40
+ if (txData.to.toLowerCase() !== contractAddress.toLowerCase()) {
41
+ throw new Error('Transaction target mismatch');
42
+ }
43
+ const { operation, request } = decodeTransactionOperation(
44
+ contractAddress,
45
+ txData.data,
46
+ chainId,
29
47
  );
30
-
31
- return result;
48
+ return this.executeOperation(operation, request.params);
32
49
  }
33
50
 
34
51
  async pushPendingTransaction(
@@ -0,0 +1,197 @@
1
+ import { AbiCoder, Interface, Result } from 'ethers';
2
+ import {
3
+ buildTransactionOperation,
4
+ CommandType,
5
+ ContractType,
6
+ CoreAbi,
7
+ getAddress,
8
+ OrdersGatewayAbi,
9
+ PeripheryAbi,
10
+ TransactionOperation,
11
+ TransactionOperationParams,
12
+ TransactionOperationSignature,
13
+ } from '@reyaxyz/common';
14
+
15
+ const core = new Interface(CoreAbi);
16
+ const periphery = new Interface(PeripheryAbi);
17
+ const gateway = new Interface(OrdersGatewayAbi);
18
+
19
+ type OperationRequest = {
20
+ [K in TransactionOperation]: {
21
+ operation: K;
22
+ request: { params: TransactionOperationParams[K] };
23
+ };
24
+ }[TransactionOperation];
25
+
26
+ const signature = (sig: Result): TransactionOperationSignature => ({
27
+ v: Number(sig.v) as 27 | 28,
28
+ r: sig.r,
29
+ s: sig.s,
30
+ deadline: sig.deadline.toString(),
31
+ });
32
+
33
+ /** Keeps existing SDK signing APIs while removing raw calldata from HTTP. */
34
+ export function decodeTransactionOperation(
35
+ target: string,
36
+ data: string,
37
+ chainId: number,
38
+ ): OperationRequest {
39
+ const decoded = decode(target, data, chainId);
40
+ const { call } = buildTransactionOperation(
41
+ decoded.operation,
42
+ decoded.request,
43
+ chainId,
44
+ );
45
+ // Never silently change a signed payload, accept trailing bytes, or widen an
46
+ // unsupported execute batch into an operation. There is no legacy fallback.
47
+ if (
48
+ call.target.toLowerCase() !== target.toLowerCase() ||
49
+ call.callData.toLowerCase() !== data.toLowerCase()
50
+ ) {
51
+ throw new Error('Unsupported transaction operation');
52
+ }
53
+ return decoded;
54
+ }
55
+
56
+ function decode(
57
+ target: string,
58
+ data: string,
59
+ chainId: number,
60
+ ): OperationRequest {
61
+ const isTarget = (contract: ContractType) =>
62
+ target.toLowerCase() === getAddress(chainId, contract).toLowerCase();
63
+ if (isTarget(ContractType.CORE_PROXY)) {
64
+ const tx = core.parseTransaction({ data });
65
+ if (tx?.name === 'createAccount') {
66
+ return {
67
+ operation: 'create-account',
68
+ request: { params: { owner: tx.args.accountOwner } },
69
+ };
70
+ }
71
+ }
72
+ if (isTarget(ContractType.ORDERS_GATEWAY_PROXY)) {
73
+ const tx = gateway.parseTransaction({ data });
74
+ if (tx?.name === 'managePermissionBySig') {
75
+ return {
76
+ operation: tx.args.permissionState
77
+ ? 'enable-api-wallet'
78
+ : 'disable-api-wallet',
79
+ request: {
80
+ params: {
81
+ owner: tx.args.owner,
82
+ apiWallet: tx.args.target,
83
+ sig: signature(tx.args.sig),
84
+ },
85
+ },
86
+ };
87
+ }
88
+ }
89
+ if (isTarget(ContractType.PERIPHERY_PROXY)) {
90
+ const tx = periphery.parseTransaction({ data });
91
+ const p = tx?.args[0];
92
+ switch (tx?.name) {
93
+ case 'transferFromMAToMA':
94
+ return {
95
+ operation: 'transfer',
96
+ request: {
97
+ params: {
98
+ accountId: p.accountId.toString(),
99
+ toAccountId: p.transfer.destAccountId.toString(),
100
+ token: p.transfer.collateral,
101
+ tokenAmount: p.transfer.collateralAmount.toString(),
102
+ sig: signature(p.sig),
103
+ },
104
+ },
105
+ };
106
+ case 'withdrawMA':
107
+ return {
108
+ operation: 'withdraw',
109
+ request: {
110
+ params: {
111
+ accountId: p.accountId.toString(),
112
+ token: p.token,
113
+ tokenAmount: p.tokenAmount.toString(),
114
+ sig: signature(p.sig),
115
+ receiver: p.receiver,
116
+ chainId: p.chainId.toString(),
117
+ socketMsgGasLimit: p.socketMsgGasLimit.toString(),
118
+ },
119
+ },
120
+ };
121
+ case 'withdrawMALZ':
122
+ return {
123
+ operation: 'withdraw-lz',
124
+ request: {
125
+ params: {
126
+ accountId: p.accountId.toString(),
127
+ token: p.token,
128
+ tokenAmount: p.tokenAmount.toString(),
129
+ sig: signature(p.sig),
130
+ receiver: p.receiver,
131
+ dstEid: p.dstEid.toString(),
132
+ },
133
+ },
134
+ };
135
+ case 'depositLiquidityToAccount':
136
+ return {
137
+ operation: 'deposit-pool',
138
+ request: {
139
+ params: {
140
+ accountId: p.accountId.toString(),
141
+ poolId: p.poolId.toString(),
142
+ sharesAmount: p.sharesAmount.toString(),
143
+ sig: signature(p.sig),
144
+ },
145
+ },
146
+ };
147
+ case 'withdrawPassivePool':
148
+ return {
149
+ operation: 'withdraw-pool',
150
+ request: {
151
+ params: {
152
+ owner: p.owner,
153
+ poolId: p.poolId.toString(),
154
+ sharesAmount: p.sharesAmount.toString(),
155
+ minOut: p.minOut.toString(),
156
+ sig: signature(p.sig),
157
+ socketMsgGasLimit: p.socketMsgGasLimit.toString(),
158
+ chainId: p.chainId.toString(),
159
+ receiver: p.receiver,
160
+ },
161
+ },
162
+ };
163
+ case 'execute': {
164
+ if (p.commands.length !== 1) break;
165
+ const command = p.commands[0];
166
+ if (
167
+ Number(command.commandType) !== CommandType.MANAGE_POOL_STAKE ||
168
+ command.marketId !== BigInt(0) ||
169
+ command.exchangeId !== BigInt(0)
170
+ )
171
+ break;
172
+ const [direction, inputs] = AbiCoder.defaultAbiCoder().decode(
173
+ ['uint8', 'bytes'],
174
+ command.inputs,
175
+ );
176
+ if (direction !== BigInt(0) && direction !== BigInt(1)) break;
177
+ const [poolId, amount, minimumOut] = AbiCoder.defaultAbiCoder().decode(
178
+ ['uint128', 'uint256', 'uint256'],
179
+ inputs,
180
+ );
181
+ return {
182
+ operation: direction === BigInt(0) ? 'stake' : 'unstake',
183
+ request: {
184
+ params: {
185
+ accountId: p.accountId.toString(),
186
+ poolId: poolId.toString(),
187
+ amount: amount.toString(),
188
+ minimumOut: minimumOut.toString(),
189
+ sig: signature(p.sig),
190
+ },
191
+ },
192
+ };
193
+ }
194
+ }
195
+ }
196
+ throw new Error('Unsupported transaction operation');
197
+ }
@@ -8,7 +8,9 @@ import {
8
8
 
9
9
  export type CreateAccountParams = {
10
10
  ownerAddress: string;
11
- name: string;
11
+ /** @deprecated Ignored. Set the name through the authenticated account-name API after creation. */
12
+ name?: string;
13
+ /** @deprecated Ignored by the dedicated create-account endpoint. */
12
14
  source?: string;
13
15
  };
14
16
 
@@ -3,7 +3,8 @@ import { Address, OFTMessagingFee } from '@reyaxyz/common';
3
3
 
4
4
  export type CreateAccountParamsV2 = {
5
5
  ownerAddress: string;
6
- name: string;
6
+ /** @deprecated Ignored. Set the name through the authenticated account-name API after creation. */
7
+ name?: string;
7
8
  };
8
9
 
9
10
  export type CreateAccountResultV2 = {
@@ -23,18 +23,12 @@ export async function signAndBroadcastTransaction(
23
23
  try {
24
24
  const transactionModuleClient = getTransactionModuleClient();
25
25
 
26
- // Add client-side timestamp and timezone to measure latency and location
27
- const metadataWithTimestamp: TransactionExecutionMetadata = {
28
- ...metadata,
29
- clientSentTimestamp: Date.now(),
30
- clientTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
31
- };
32
-
33
26
  transactionExecutionOutput =
34
27
  await transactionModuleClient.executeTransaction(
35
28
  { to: contractAddress, data: data },
36
29
  contractAddress,
37
- metadataWithTimestamp,
30
+ metadata,
31
+ chainId,
38
32
  );
39
33
  } catch (error) {
40
34
  const stringifiedError = stringifyObject(error);