@otim/sdk-core 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/account/index.cjs +1 -1
- package/dist/{account-CRvC_dXT.cjs → account-Bwm5PTcc.cjs} +3 -8
- package/dist/account-Bwm5PTcc.cjs.map +1 -0
- package/dist/clients/index.cjs +4 -1
- package/dist/{clients-CXapnxYY.cjs → clients-CeCv_iST.cjs} +60 -28
- package/dist/clients-CeCv_iST.cjs.map +1 -0
- package/dist/config/index.cjs +1 -1
- package/dist/{config-CjGpscVk.cjs → config-BrvU6CD_.cjs} +2 -2
- package/dist/{config-CjGpscVk.cjs.map → config-BrvU6CD_.cjs.map} +1 -1
- package/dist/context/index.cjs +1 -1
- package/dist/{context-B-Wcmhb3.cjs → context-DK5bXjx4.cjs} +1 -1
- package/dist/{context-B-Wcmhb3.cjs.map → context-DK5bXjx4.cjs.map} +1 -1
- package/dist/index.cjs +18 -9
- package/dist/signing/index.cjs +10 -0
- package/dist/signing-BaJMYH0K.cjs +1096 -0
- package/dist/signing-BaJMYH0K.cjs.map +1 -0
- package/dist/utils/index.cjs +5 -5
- package/dist/{utils-CVQFvsfl.cjs → vrs-Do0jfo3H.cjs} +1 -1
- package/dist/vrs-Do0jfo3H.cjs.map +1 -0
- package/package.json +17 -5
- package/dist/abi-DW6AS0eM.d.mts +0 -339
- package/dist/abi-DW6AS0eM.d.mts.map +0 -1
- package/dist/abi-OUq-mx1W.d.cts +0 -339
- package/dist/abi-OUq-mx1W.d.cts.map +0 -1
- package/dist/account/index.d.cts +0 -5
- package/dist/account/index.d.mts +0 -5
- package/dist/account/index.mjs +0 -3
- package/dist/account-CRvC_dXT.cjs.map +0 -1
- package/dist/account-D1NVta26.mjs +0 -31
- package/dist/account-D1NVta26.mjs.map +0 -1
- package/dist/authorization-6anhDdQX.d.cts +0 -210
- package/dist/authorization-6anhDdQX.d.cts.map +0 -1
- package/dist/authorization-DnNpWjxB.d.mts +0 -210
- package/dist/authorization-DnNpWjxB.d.mts.map +0 -1
- package/dist/clients/index.d.cts +0 -3
- package/dist/clients/index.d.mts +0 -3
- package/dist/clients/index.mjs +0 -3
- package/dist/clients-CXapnxYY.cjs.map +0 -1
- package/dist/clients-exLOdQVD.mjs +0 -217
- package/dist/clients-exLOdQVD.mjs.map +0 -1
- package/dist/config/index.d.cts +0 -3
- package/dist/config/index.d.mts +0 -3
- package/dist/config/index.mjs +0 -3
- package/dist/config-C_nc1DXn.mjs +0 -67
- package/dist/config-C_nc1DXn.mjs.map +0 -1
- package/dist/context/index.d.cts +0 -5
- package/dist/context/index.d.mts +0 -5
- package/dist/context/index.mjs +0 -3
- package/dist/context-uTye69B0.mjs +0 -20
- package/dist/context-uTye69B0.mjs.map +0 -1
- package/dist/index-BQMXYh9N.d.cts +0 -14
- package/dist/index-BQMXYh9N.d.cts.map +0 -1
- package/dist/index-C5c51xs0.d.mts +0 -51
- package/dist/index-C5c51xs0.d.mts.map +0 -1
- package/dist/index-C8H-BPGH.d.cts +0 -51
- package/dist/index-C8H-BPGH.d.cts.map +0 -1
- package/dist/index-CBQ5I-Uz.d.cts +0 -103
- package/dist/index-CBQ5I-Uz.d.cts.map +0 -1
- package/dist/index-CnjY7cyS.d.mts +0 -14
- package/dist/index-CnjY7cyS.d.mts.map +0 -1
- package/dist/index-D8OoAxEI.d.mts +0 -103
- package/dist/index-D8OoAxEI.d.mts.map +0 -1
- package/dist/index-DWE1xfOE.d.mts +0 -23
- package/dist/index-DWE1xfOE.d.mts.map +0 -1
- package/dist/index-D_7CTJDl.d.mts +0 -27
- package/dist/index-D_7CTJDl.d.mts.map +0 -1
- package/dist/index-GSspyLr3.d.cts +0 -23
- package/dist/index-GSspyLr3.d.cts.map +0 -1
- package/dist/index-lW-Oor1B.d.cts +0 -27
- package/dist/index-lW-Oor1B.d.cts.map +0 -1
- package/dist/index.d.cts +0 -9
- package/dist/index.d.mts +0 -9
- package/dist/index.mjs +0 -7
- package/dist/rpc-BDoNl1Sp.d.cts +0 -6885
- package/dist/rpc-BDoNl1Sp.d.cts.map +0 -1
- package/dist/rpc-CygBD_f7.d.mts +0 -6885
- package/dist/rpc-CygBD_f7.d.mts.map +0 -1
- package/dist/utils/index.d.cts +0 -4
- package/dist/utils/index.d.mts +0 -4
- package/dist/utils/index.mjs +0 -3
- package/dist/utils-CVQFvsfl.cjs.map +0 -1
- package/dist/utils-DziAHBiz.mjs +0 -81
- package/dist/utils-DziAHBiz.mjs.map +0 -1
package/dist/account/index.cjs
CHANGED
|
@@ -15,15 +15,10 @@ function isPrivateKeyAccountConfig(config) {
|
|
|
15
15
|
return config.type === ServerAccountType.PrivateKey;
|
|
16
16
|
}
|
|
17
17
|
function createClientContext(config) {
|
|
18
|
-
const usesApiKeyAuth = isApiAccountConfig(config) && config.apiKey !== void 0;
|
|
19
|
-
const defaultChain = config.defaultChain ?? config.chains[0];
|
|
20
|
-
if (!defaultChain) throw new Error("At least one chain must be provided");
|
|
21
18
|
return {
|
|
22
|
-
usesApiKeyAuth,
|
|
19
|
+
usesApiKeyAuth: isApiAccountConfig(config) && config.apiKey !== void 0,
|
|
23
20
|
config,
|
|
24
|
-
accountType: config.type
|
|
25
|
-
chains: config.chains,
|
|
26
|
-
defaultChain
|
|
21
|
+
accountType: config.type
|
|
27
22
|
};
|
|
28
23
|
}
|
|
29
24
|
|
|
@@ -58,4 +53,4 @@ Object.defineProperty(exports, 'isPrivateKeyAccountConfig', {
|
|
|
58
53
|
return isPrivateKeyAccountConfig;
|
|
59
54
|
}
|
|
60
55
|
});
|
|
61
|
-
//# sourceMappingURL=account-
|
|
56
|
+
//# sourceMappingURL=account-Bwm5PTcc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-Bwm5PTcc.cjs","names":[],"sources":["../src/account/types.ts","../src/account/helpers.ts"],"sourcesContent":["import type { Environment } from \"@otim/sdk-core/config\";\nimport type { Hex } from \"viem\";\n\nexport const ServerAccountType = {\n PrivateKey: \"privateKey\",\n Api: \"api\",\n} as const;\nexport type ServerAccountType =\n (typeof ServerAccountType)[keyof typeof ServerAccountType];\n\nexport const AccountType = {\n ...ServerAccountType,\n} as const;\nexport type AccountType = (typeof AccountType)[keyof typeof AccountType];\n\nexport type OtimAccountSignMessageArgs = {\n message: string | { raw: Hex | Uint8Array };\n};\n\nexport interface OtimAccount {\n initialize(): Promise<void>;\n signMessage(args: OtimAccountSignMessageArgs): Promise<Hex>;\n}\n\ninterface BaseAccountConfig {\n environment?: Environment;\n}\n\nexport interface ApiAccountConfig extends BaseAccountConfig {\n type: typeof ServerAccountType.Api;\n appId: string;\n privateKey: string;\n publicKey: string;\n apiKey?: string;\n}\n\nexport interface PrivateKeyAccountConfig extends BaseAccountConfig {\n type: typeof ServerAccountType.PrivateKey;\n privateKey: `0x${string}`;\n}\n\nexport type ServerAccountConfig = ApiAccountConfig | PrivateKeyAccountConfig;\n\nexport type AccountConfig = ServerAccountConfig;\n","import type {\n ApiAccountConfig,\n PrivateKeyAccountConfig,\n ServerAccountConfig,\n} from \"./types\";\nimport type { OtimServerClientContext } from \"@otim/sdk-core/context\";\n\nimport { ServerAccountType } from \"./types\";\n\nexport function isApiAccountConfig(\n config: ServerAccountConfig,\n): config is ApiAccountConfig {\n return config.type === ServerAccountType.Api;\n}\n\nexport function isPrivateKeyAccountConfig(\n config: ServerAccountConfig,\n): config is PrivateKeyAccountConfig {\n return config.type === ServerAccountType.PrivateKey;\n}\n\nexport function createClientContext(\n config: ServerAccountConfig,\n): OtimServerClientContext {\n const usesApiKeyAuth =\n isApiAccountConfig(config) && config.apiKey !== undefined;\n\n return {\n usesApiKeyAuth,\n config,\n accountType: config.type,\n };\n}\n"],"mappings":";;AAGA,MAAa,oBAAoB;CAC/B,YAAY;CACZ,KAAK;CACN;AAID,MAAa,cAAc,EACzB,GAAG,mBACJ;;;;ACHD,SAAgB,mBACd,QAC4B;AAC5B,QAAO,OAAO,SAAS,kBAAkB;;AAG3C,SAAgB,0BACd,QACmC;AACnC,QAAO,OAAO,SAAS,kBAAkB;;AAG3C,SAAgB,oBACd,QACyB;AAIzB,QAAO;EACL,gBAHA,mBAAmB,OAAO,IAAI,OAAO,WAAW;EAIhD;EACA,aAAa,OAAO;EACrB"}
|
package/dist/clients/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
require('../account-Bwm5PTcc.cjs');
|
|
2
|
+
const require_clients = require('../clients-CeCv_iST.cjs');
|
|
3
|
+
require('../signing-BaJMYH0K.cjs');
|
|
2
4
|
|
|
3
5
|
exports.ActivityClient = require_clients.ActivityClient;
|
|
4
6
|
exports.AuthClient = require_clients.AuthClient;
|
|
5
7
|
exports.ConfigClient = require_clients.ConfigClient;
|
|
6
8
|
exports.DelegationClient = require_clients.DelegationClient;
|
|
7
9
|
exports.OrchestrationClient = require_clients.OrchestrationClient;
|
|
10
|
+
exports.createSettlementSigner = require_clients.createSettlementSigner;
|
|
8
11
|
exports.prepareSettlement = require_clients.prepareSettlement;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const require_account = require('./account-Bwm5PTcc.cjs');
|
|
2
|
+
const require_signing = require('./signing-BaJMYH0K.cjs');
|
|
1
3
|
let __otim_utils_helpers = require("@otim/utils/helpers");
|
|
2
4
|
let __otim_sdk_core_config = require("@otim/sdk-core/config");
|
|
3
5
|
let __otim_sdk_core_context = require("@otim/sdk-core/context");
|
|
@@ -5,9 +7,7 @@ let __otim_utils_chains = require("@otim/utils/chains");
|
|
|
5
7
|
let __otim_utils_payments = require("@otim/utils/payments");
|
|
6
8
|
let __otim_utils_schemas = require("@otim/utils/schemas");
|
|
7
9
|
let viem = require("viem");
|
|
8
|
-
let __otim_turnkey_signing = require("@otim/turnkey/signing");
|
|
9
10
|
let viem_accounts = require("viem/accounts");
|
|
10
|
-
let __otim_sdk_core_account = require("@otim/sdk-core/account");
|
|
11
11
|
|
|
12
12
|
//#region src/clients/activity.ts
|
|
13
13
|
var ActivityClient = class {
|
|
@@ -76,9 +76,9 @@ var DelegationClient = class {
|
|
|
76
76
|
//#region src/clients/helpers/settlement-signer.ts
|
|
77
77
|
async function createSettlementSigner(params) {
|
|
78
78
|
const { context, buildResponse, publicClient, delegateAddressMap } = params;
|
|
79
|
-
if (
|
|
79
|
+
if (require_account.isApiAccountConfig(context.config)) return new require_signing.UnifiedPaymentSigner({
|
|
80
80
|
buildResponse,
|
|
81
|
-
signingService: new
|
|
81
|
+
signingService: new require_signing.ApiKeyClientSigningService(context.config.publicKey, context.config.privateKey),
|
|
82
82
|
publicClient,
|
|
83
83
|
delegateAddressMap
|
|
84
84
|
}).signAll();
|
|
@@ -86,9 +86,9 @@ async function createSettlementSigner(params) {
|
|
|
86
86
|
account: (0, viem_accounts.privateKeyToAccount)(context.config.privateKey),
|
|
87
87
|
transport: (0, viem.http)()
|
|
88
88
|
});
|
|
89
|
-
return new
|
|
89
|
+
return new require_signing.UnifiedPaymentSigner({
|
|
90
90
|
buildResponse,
|
|
91
|
-
signingService:
|
|
91
|
+
signingService: require_signing.ServerWalletSigningService.fromViemWallet(walletClient),
|
|
92
92
|
publicClient,
|
|
93
93
|
delegateAddressMap
|
|
94
94
|
}).signAll();
|
|
@@ -102,10 +102,11 @@ var OrchestrationClient = class {
|
|
|
102
102
|
this.account = account;
|
|
103
103
|
this.context = context;
|
|
104
104
|
}
|
|
105
|
-
async create(
|
|
105
|
+
async create(settlementRequest) {
|
|
106
106
|
(0, __otim_sdk_core_context.assertServerContext)(this.context);
|
|
107
|
-
const buildResponse = (await this.apiClient.payments.buildSettlementOrchestration(
|
|
108
|
-
|
|
107
|
+
const buildResponse = (await this.apiClient.payments.buildSettlementOrchestration(settlementRequest)).data;
|
|
108
|
+
const settlementChainId = "settlement" in settlementRequest.params ? settlementRequest.params.settlement.settlementChainId : settlementRequest.params.vaultWithdrawSettlement.settlementChainId;
|
|
109
|
+
await this.activate(buildResponse, settlementChainId);
|
|
109
110
|
return {
|
|
110
111
|
requestId: buildResponse.requestId,
|
|
111
112
|
ephemeralWalletAddress: buildResponse.ephemeralWalletAddress
|
|
@@ -169,16 +170,28 @@ var OrchestrationClient = class {
|
|
|
169
170
|
|
|
170
171
|
//#endregion
|
|
171
172
|
//#region src/clients/helpers/prepare-settlement.ts
|
|
173
|
+
/**
|
|
174
|
+
* Generates a default due date 30 days from now.
|
|
175
|
+
* This is a standard payment term when no due date is specified.
|
|
176
|
+
*/
|
|
177
|
+
function getDefaultDueDate() {
|
|
178
|
+
const date = /* @__PURE__ */ new Date();
|
|
179
|
+
date.setDate(date.getDate() + 30);
|
|
180
|
+
return date.toISOString();
|
|
181
|
+
}
|
|
172
182
|
function buildMetadataFromParams(params) {
|
|
173
183
|
const { amount, recipient, token, note, dueDate, payer, customMetadata } = params;
|
|
174
184
|
const metadataWithToken = {
|
|
175
185
|
...(0, __otim_utils_payments.buildPaymentMetadata)({
|
|
176
186
|
tokenSymbol: "",
|
|
177
|
-
amountInUSD: amount,
|
|
187
|
+
amountInUSD: Number(amount) / 1e6,
|
|
178
188
|
fromAccountAddress: recipient,
|
|
179
189
|
note,
|
|
180
|
-
payer
|
|
181
|
-
|
|
190
|
+
payer: {
|
|
191
|
+
name: "",
|
|
192
|
+
address: payer ?? recipient
|
|
193
|
+
},
|
|
194
|
+
dueDate: dueDate || getDefaultDueDate()
|
|
182
195
|
}),
|
|
183
196
|
token,
|
|
184
197
|
source: "Manual",
|
|
@@ -189,26 +202,39 @@ function buildMetadataFromParams(params) {
|
|
|
189
202
|
...customMetadata
|
|
190
203
|
} : metadataWithToken;
|
|
191
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Converts acceptedTokens from Record<number, Address[]> to Record<string,
|
|
207
|
+
* Address[]> as required by the API schema.
|
|
208
|
+
*/
|
|
209
|
+
function convertAcceptedTokensToStringKeys(acceptedTokens) {
|
|
210
|
+
const result = {};
|
|
211
|
+
for (const [chainId, tokens] of Object.entries(acceptedTokens)) result[String(chainId)] = tokens;
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
192
214
|
function prepareSettlement(params) {
|
|
193
215
|
const { chainId, token, acceptedTokens, recipient, amount, payer, note, dueDate, metadata: customMetadata, maxRuns } = params;
|
|
194
216
|
if (dueDate) (0, __otim_utils_helpers.validateIso8601Date)(dueDate);
|
|
217
|
+
const metadata = buildMetadataFromParams({
|
|
218
|
+
amount,
|
|
219
|
+
recipient,
|
|
220
|
+
token,
|
|
221
|
+
note,
|
|
222
|
+
dueDate,
|
|
223
|
+
payer: payer ?? void 0,
|
|
224
|
+
customMetadata
|
|
225
|
+
});
|
|
195
226
|
return {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
recipient,
|
|
204
|
-
token,
|
|
205
|
-
note,
|
|
206
|
-
dueDate,
|
|
207
|
-
payer: payer ?? void 0,
|
|
208
|
-
customMetadata
|
|
209
|
-
}),
|
|
227
|
+
params: { settlement: {
|
|
228
|
+
acceptedTokens: convertAcceptedTokensToStringKeys(acceptedTokens),
|
|
229
|
+
settlementChainId: chainId,
|
|
230
|
+
settlementToken: token,
|
|
231
|
+
settlementAmount: (0, viem.toHex)(amount),
|
|
232
|
+
recipientAddress: recipient
|
|
233
|
+
} },
|
|
210
234
|
payerAddress: payer ?? null,
|
|
211
|
-
|
|
235
|
+
metadata,
|
|
236
|
+
dueDate: dueDate ?? null,
|
|
237
|
+
maxRuns: maxRuns ?? null
|
|
212
238
|
};
|
|
213
239
|
}
|
|
214
240
|
|
|
@@ -243,10 +269,16 @@ Object.defineProperty(exports, 'OrchestrationClient', {
|
|
|
243
269
|
return OrchestrationClient;
|
|
244
270
|
}
|
|
245
271
|
});
|
|
272
|
+
Object.defineProperty(exports, 'createSettlementSigner', {
|
|
273
|
+
enumerable: true,
|
|
274
|
+
get: function () {
|
|
275
|
+
return createSettlementSigner;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
246
278
|
Object.defineProperty(exports, 'prepareSettlement', {
|
|
247
279
|
enumerable: true,
|
|
248
280
|
get: function () {
|
|
249
281
|
return prepareSettlement;
|
|
250
282
|
}
|
|
251
283
|
});
|
|
252
|
-
//# sourceMappingURL=clients-
|
|
284
|
+
//# sourceMappingURL=clients-CeCv_iST.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients-CeCv_iST.cjs","names":["apiClient: APIClient","apiClient: APIClient","account: OtimAccount","context: OtimClientContext","apiClient: APIClient","apiClient: APIClient","isApiAccountConfig","UnifiedPaymentSigner","ApiKeyClientSigningService","ServerWalletSigningService","apiClient: APIClient","account: OtimAccount","context: OtimServerClientContext","hexStringSchema","result: Record<string, Address[]>"],"sources":["../src/clients/activity.ts","../src/clients/auth.ts","../src/clients/config.ts","../src/clients/delegation.ts","../src/clients/helpers/settlement-signer.ts","../src/clients/orchestration.ts","../src/clients/helpers/prepare-settlement.ts"],"sourcesContent":["import type {\n APIClient,\n GetInstructionActivityRequest,\n GetInstructionActivityResponse,\n} from \"@otim/utils/api\";\n\nexport class ActivityClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getInstructionActivity(\n request: GetInstructionActivityRequest,\n ): Promise<GetInstructionActivityResponse> {\n const response =\n await this.apiClient.activity.getInstructionActivity(request);\n\n return response.data;\n }\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimClientContext } from \"@otim/sdk-core/context\";\nimport type { APIClient, AuthLoginResponse, MeResponse } from \"@otim/utils/api\";\nimport type { Address } from \"viem\";\n\nimport { parseSignatureToVRS } from \"@otim/utils/helpers\";\n\nimport { createLoginSiweMessage } from \"@otim/sdk-core/config\";\nimport { assertRequiresAuth } from \"@otim/sdk-core/context\";\n\nexport interface LoginOptions {\n address: Address;\n}\n\nexport class AuthClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimClientContext,\n ) {}\n\n async login({ address }: LoginOptions): Promise<AuthLoginResponse> {\n assertRequiresAuth(this.context);\n\n const message = createLoginSiweMessage(address, Date.now().toString());\n const signature = await this.account.signMessage({ message });\n const vrsParsedSignature = parseSignatureToVRS(signature);\n\n const response = await this.apiClient.auth.login({\n siwe: message,\n signature: vrsParsedSignature,\n });\n\n return response.data;\n }\n\n async getCurrentUser(): Promise<MeResponse> {\n const response = await this.apiClient.auth.me();\n return response.data;\n }\n}\n","import type {\n APIClient,\n GetMaxPriorityFeePerGasEstimateRequest,\n GetMaxPriorityFeePerGasEstimateResponse,\n} from \"@otim/utils/api\";\n\nexport class ConfigClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getMaxPriorityFeeEstimate({\n chainId,\n }: GetMaxPriorityFeePerGasEstimateRequest): Promise<GetMaxPriorityFeePerGasEstimateResponse> {\n const response =\n await this.apiClient.config.getMaxPriorityFeePerGasEstimate({ chainId });\n\n return response.data;\n }\n}\n","import type {\n APIClient,\n DelegationCreateRequest,\n DelegationStatusRequest,\n DelegationStatusResponse,\n GetDelegateAddressRequest,\n GetDelegateAddressResponse,\n} from \"@otim/utils/api\";\n\nexport class DelegationClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getDelegateAddress({\n chainId,\n }: GetDelegateAddressRequest): Promise<GetDelegateAddressResponse> {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n\n return response.data;\n }\n\n async getDelegationStatus(\n options: DelegationStatusRequest,\n ): Promise<DelegationStatusResponse> {\n const response = await this.apiClient.account.getDelegationStatus({\n address: options.address,\n chainId: options.chainId,\n });\n\n return response.data;\n }\n\n async createDelegation(\n delegationRequest: DelegationCreateRequest,\n ): Promise<void> {\n await this.apiClient.account.createDelegation(delegationRequest);\n }\n}\n","import type { OtimServerClientContext } from \"../../context\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\nimport type { PublicClient } from \"viem\";\n\nimport { createWalletClient, http } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\n\nimport { isApiAccountConfig } from \"../../account\";\nimport {\n ApiKeyClientSigningService,\n ServerWalletSigningService,\n UnifiedPaymentSigner,\n} from \"../../signing\";\n\nexport interface CreateSettlementSignerParams {\n context: OtimServerClientContext;\n buildResponse: PaymentResponseWithActionNames;\n publicClient: PublicClient;\n delegateAddressMap: Map<number, Address>;\n}\n\ntype CreateSettlementSignerResult = Awaited<\n ReturnType<UnifiedPaymentSigner[\"signAll\"]>\n>;\n\nexport async function createSettlementSigner(\n params: CreateSettlementSignerParams,\n): Promise<CreateSettlementSignerResult> {\n const { context, buildResponse, publicClient, delegateAddressMap } = params;\n\n if (isApiAccountConfig(context.config)) {\n const signingService = new ApiKeyClientSigningService(\n context.config.publicKey,\n context.config.privateKey,\n );\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n }\n\n const account = privateKeyToAccount(context.config.privateKey);\n const walletClient = createWalletClient({\n account,\n transport: http(),\n });\n\n const signingService =\n ServerWalletSigningService.fromViemWallet(walletClient);\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimServerClientContext } from \"@otim/sdk-core/context\";\nimport type {\n APIClient,\n BuildSettlementRequest,\n GetPaymentRequestsRequest,\n GetPaymentRequestsResponse,\n PaginatedServiceResponse,\n PaymentRequestBuildRequest,\n PaymentRequestDetailsRequest,\n PaymentRequestDetailsResponse,\n ServiceResponse,\n} from \"@otim/utils/api\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\nimport type { Chain, PublicClient } from \"viem\";\n\nimport { getChainById } from \"@otim/utils/chains\";\nimport {\n addActionNamesToInstructions,\n extractActionNamesMap,\n} from \"@otim/utils/payments\";\nimport { hexStringSchema } from \"@otim/utils/schemas\";\nimport { createPublicClient, http } from \"viem\";\n\nimport { assertServerContext } from \"@otim/sdk-core/context\";\n\nimport { createSettlementSigner } from \"./helpers/settlement-signer\";\n\nexport interface CreateSettlementResponse {\n requestId: string;\n ephemeralWalletAddress: Address;\n}\n\nexport interface CreateRawConfig {\n settlementChainId: number;\n activate?: boolean;\n}\n\ntype SettlementInstruction =\n PaymentResponseWithActionNames[\"completionInstructions\"][number];\n\nexport class OrchestrationClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimServerClientContext,\n ) {}\n\n async create(\n settlementRequest: BuildSettlementRequest,\n ): Promise<CreateSettlementResponse> {\n assertServerContext(this.context);\n\n const response =\n await this.apiClient.payments.buildSettlementOrchestration(\n settlementRequest,\n );\n const buildResponse = response.data;\n\n /* Extract settlementChainId from the params structure */\n const settlementChainId =\n \"settlement\" in settlementRequest.params\n ? settlementRequest.params.settlement.settlementChainId\n : settlementRequest.params.vaultWithdrawSettlement.settlementChainId;\n\n await this.activate(buildResponse, settlementChainId);\n\n return {\n requestId: buildResponse.requestId,\n ephemeralWalletAddress: buildResponse.ephemeralWalletAddress,\n };\n }\n\n async createRaw(\n payload: PaymentRequestBuildRequest,\n config: CreateRawConfig,\n ): Promise<CreateSettlementResponse | PaymentResponseWithActionNames> {\n assertServerContext(this.context);\n\n const { settlementChainId, activate = true } = config;\n const buildResponse = await this.buildAndEnhanceSettlement(payload);\n\n if (!activate) {\n return buildResponse;\n }\n\n await this.activate(buildResponse, settlementChainId);\n\n return {\n requestId: buildResponse.requestId,\n ephemeralWalletAddress: buildResponse.ephemeralWalletAddress,\n };\n }\n\n async getDetails(\n request: PaymentRequestDetailsRequest,\n ): Promise<ServiceResponse<PaymentRequestDetailsResponse>> {\n return this.apiClient.payments.getPaymentRequestDetails(request);\n }\n\n async list(\n request: GetPaymentRequestsRequest,\n ): Promise<PaginatedServiceResponse<GetPaymentRequestsResponse>> {\n return this.apiClient.payments.getPaymentRequests(request);\n }\n\n private async activate(\n buildResponse: PaymentResponseWithActionNames,\n settlementChainId: number,\n ): Promise<void> {\n const publicClient = this.createPublicClient(settlementChainId);\n\n const instructions = [\n ...buildResponse.completionInstructions,\n ...buildResponse.instructions,\n ];\n\n const delegateAddressMap = await this.fetchDelegateAddresses(instructions);\n\n const {\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n } = await createSettlementSigner({\n context: this.context,\n buildResponse,\n publicClient,\n delegateAddressMap,\n });\n\n await this.apiClient.payments.newPaymentRequest({\n requestId: buildResponse.requestId,\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n });\n }\n\n private async buildAndEnhanceSettlement(\n payload: PaymentRequestBuildRequest,\n ): Promise<PaymentResponseWithActionNames> {\n const actionNames = extractActionNamesMap(\n payload.completionInstructions,\n payload.instructions,\n );\n\n const response = await this.apiClient.payments.buildPaymentRequest(payload);\n\n return addActionNamesToInstructions(response.data, actionNames);\n }\n\n private createPublicClient(chainId: number): PublicClient {\n const chain = getChainById(chainId);\n if (!chain) {\n throw new Error(`Chain with id ${chainId} not found`);\n }\n\n return createPublicClient({ chain: chain as Chain, transport: http() });\n }\n\n private async fetchDelegateAddresses(\n instructions: SettlementInstruction[],\n ): Promise<Map<number, Address>> {\n const chainIds = Array.from(\n new Set(instructions.map((instruction) => instruction.chainId)),\n );\n\n const addresses = await Promise.all(\n chainIds.map(async (chainId) => {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n const address = hexStringSchema.parse(\n response.data.otimDelegateAddress,\n );\n return [chainId, address] as const;\n }),\n );\n\n return new Map(addresses);\n }\n}\n","import type {\n BuildSettlementRequest,\n OrchestrationParams,\n SettlementParams,\n VaultWithdrawSettlementParams,\n} from \"@otim/utils/api\";\nimport type { SupportedChainId } from \"@otim/utils/chains\";\nimport type { Nullable } from \"@otim/utils/helpers\";\nimport type { PaymentRequestMetadata } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport { validateIso8601Date } from \"@otim/utils/helpers\";\nimport { buildPaymentMetadata } from \"@otim/utils/payments\";\nimport { toHex } from \"viem\";\n\n/**\n * Generates a default due date 30 days from now.\n * This is a standard payment term when no due date is specified.\n */\nfunction getDefaultDueDate(): string {\n const date = new Date();\n date.setDate(date.getDate() + 30);\n return date.toISOString();\n}\n\nexport type {\n BuildSettlementRequest,\n OrchestrationParams,\n SettlementParams,\n VaultWithdrawSettlementParams,\n};\n\nexport interface PrepareSettlementParams {\n amount: bigint;\n chainId: SupportedChainId;\n recipient: Address;\n token: Address;\n acceptedTokens: Record<number, Address[]>;\n payer?: Nullable<Address>;\n dueDate?: string;\n metadata?: PaymentRequestMetadata;\n note?: string;\n maxRuns?: number;\n}\n\nfunction buildMetadataFromParams(params: {\n amount: bigint;\n recipient: Address;\n token: Address;\n note?: string;\n dueDate?: string;\n payer?: Address;\n customMetadata?: PaymentRequestMetadata;\n}): PaymentRequestMetadata {\n const { amount, recipient, token, note, dueDate, payer, customMetadata } =\n params;\n\n /* Convert from smallest token units to USD */\n const amountInUSD = Number(amount) / 1_000_000;\n\n const baseMetadata = buildPaymentMetadata({\n tokenSymbol: \"\",\n amountInUSD,\n fromAccountAddress: recipient,\n note,\n payer: { name: \"\", address: payer ?? recipient },\n dueDate: dueDate || getDefaultDueDate(),\n });\n\n const metadataWithToken = {\n ...baseMetadata,\n token,\n source: \"Manual\" as const,\n type: \"PaymentRequest\" as const,\n };\n\n return customMetadata\n ? { ...metadataWithToken, ...customMetadata }\n : metadataWithToken;\n}\n\n/**\n * Converts acceptedTokens from Record<number, Address[]> to Record<string,\n * Address[]> as required by the API schema.\n */\nfunction convertAcceptedTokensToStringKeys(\n acceptedTokens: Record<number, Address[]>,\n): Record<string, Address[]> {\n const result: Record<string, Address[]> = {};\n for (const [chainId, tokens] of Object.entries(acceptedTokens)) {\n result[String(chainId)] = tokens;\n }\n return result;\n}\n\nexport function prepareSettlement(\n params: PrepareSettlementParams,\n): BuildSettlementRequest {\n const {\n chainId,\n token,\n acceptedTokens,\n recipient,\n amount,\n payer,\n note,\n dueDate,\n metadata: customMetadata,\n maxRuns,\n } = params;\n\n if (dueDate) {\n validateIso8601Date(dueDate);\n }\n\n const metadata = buildMetadataFromParams({\n amount,\n recipient,\n token,\n note,\n dueDate,\n payer: payer ?? undefined,\n customMetadata,\n });\n\n return {\n params: {\n settlement: {\n acceptedTokens: convertAcceptedTokensToStringKeys(acceptedTokens),\n settlementChainId: chainId,\n settlementToken: token,\n // @ts-expect-error -- TODO: fix this once we have the correct type definitions in @otim/utils\n settlementAmount: toHex(amount),\n recipientAddress: recipient,\n },\n },\n payerAddress: payer ?? null,\n metadata,\n dueDate: dueDate ?? null,\n maxRuns: maxRuns ?? null,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAMA,IAAa,iBAAb,MAA4B;CAC1B,YAAY,AAAiBA,WAAsB;EAAtB;;CAE7B,MAAM,uBACJ,SACyC;AAIzC,UAFE,MAAM,KAAK,UAAU,SAAS,uBAAuB,QAAQ,EAE/C;;;;;;ACDpB,IAAa,aAAb,MAAwB;CACtB,YACE,AAAiBC,WACjB,AAAiBC,SACjB,AAAiBC,SACjB;EAHiB;EACA;EACA;;CAGnB,MAAM,MAAM,EAAE,WAAqD;AACjE,kDAAmB,KAAK,QAAQ;EAEhC,MAAM,6DAAiC,SAAS,KAAK,KAAK,CAAC,UAAU,CAAC;EAEtE,MAAM,mEADY,MAAM,KAAK,QAAQ,YAAY,EAAE,SAAS,CAAC,CACJ;AAOzD,UALiB,MAAM,KAAK,UAAU,KAAK,MAAM;GAC/C,MAAM;GACN,WAAW;GACZ,CAAC,EAEc;;CAGlB,MAAM,iBAAsC;AAE1C,UADiB,MAAM,KAAK,UAAU,KAAK,IAAI,EAC/B;;;;;;AChCpB,IAAa,eAAb,MAA0B;CACxB,YAAY,AAAiBC,WAAsB;EAAtB;;CAE7B,MAAM,0BAA0B,EAC9B,WAC2F;AAI3F,UAFE,MAAM,KAAK,UAAU,OAAO,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AEjB,kCAAwB,OAAO;GAC/B,kBAAkB;GACnB,EACF;EACD,cAAc,SAAS;EACvB;EACA,SAAS,WAAW;EACpB,SAAS,WAAW;EACrB"}
|
package/dist/config/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
let __t3_oss_env_core = require("@t3-oss/env-core");
|
|
2
1
|
let zod = require("zod");
|
|
2
|
+
let __t3_oss_env_core = require("@t3-oss/env-core");
|
|
3
3
|
let viem_siwe = require("viem/siwe");
|
|
4
4
|
|
|
5
5
|
//#region src/config/env.ts
|
|
@@ -111,4 +111,4 @@ Object.defineProperty(exports, 'isEnvironment', {
|
|
|
111
111
|
return isEnvironment;
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
|
-
//# sourceMappingURL=config-
|
|
114
|
+
//# sourceMappingURL=config-BrvU6CD_.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-
|
|
1
|
+
{"version":3,"file":"config-BrvU6CD_.cjs","names":["API_URLS: Record<Environment, string>","TURNKEY_API_URLS: Record<Environment, string>","z"],"sources":["../src/config/env.ts","../src/config/app.ts"],"sourcesContent":["import { createEnv } from \"@t3-oss/env-core\";\nimport { z } from \"zod\";\n\nexport const Environment = {\n Sandbox: \"sandbox\",\n Production: \"production\",\n} as const;\nexport type Environment = (typeof Environment)[keyof typeof Environment];\n\nexport const isEnvironment = (value: string): value is Environment =>\n Object.values(Environment).includes(value as Environment);\n\nexport const environmentValues = Object.values(Environment) as [\n Environment,\n ...Environment[],\n];\n\nexport const API_URLS: Record<Environment, string> = {\n [Environment.Sandbox]: \"https://dev-cwnvii2d-api.otim.dev\",\n [Environment.Production]: \"https://api.otim.com\",\n};\n\nexport const TURNKEY_API_URLS: Record<Environment, string> = {\n [Environment.Sandbox]: \"https://api.turnkey.com\",\n [Environment.Production]: \"https://api.turnkey.com\",\n};\n\nexport const getApiUrl = (environment: Environment): string => {\n return API_URLS[environment];\n};\n\nexport const getTurnkeyApiUrl = (environment: Environment): string => {\n return TURNKEY_API_URLS[environment];\n};\n\nexport const env = createEnv({\n server: {\n ENVIRONMENT: z.enum(environmentValues).default(Environment.Sandbox),\n\n ENABLE_MSW: z.coerce.boolean().default(false),\n\n CI: z.coerce.boolean().default(false),\n },\n\n client: {},\n\n clientPrefix: \"\",\n\n runtimeEnv: {\n ENVIRONMENT: process.env.ENVIRONMENT,\n\n ENABLE_MSW: process.env.ENABLE_MSW,\n\n CI: process.env.CI,\n },\n\n onValidationError: (error) => {\n // eslint-disable-next-line no-console\n console.error(\"❌ Invalid environment variables:\", error);\n throw new Error(\"Invalid environment variables\");\n },\n\n // skip validation of environment variables (should be false in most cases)\n skipValidation: process.env.SKIP_ENV_VALIDATION === \"true\",\n});\n","import type { Address } from \"viem\";\n\nimport { createSiweMessage } from \"viem/siwe\";\n\n/**\n * SIWE default configuration.\n */\nexport const SIWE_CHAIN_ID = 0;\nexport const SIWE_VERSION = \"1\";\n\nexport const createLoginSiweMessage = (\n address: Address,\n nonce: string,\n): string => {\n return createSiweMessage({\n address,\n chainId: SIWE_CHAIN_ID,\n nonce,\n domain: \"otim.com\",\n uri: \"https://app.otim.com\",\n statement: `Welcome to Otim! By signing in, you accept the Otim Terms and Conditions (https://otim.com/tac). This request will not trigger a blockchain transaction or cost any gas fees.`,\n version: SIWE_VERSION,\n });\n};\n"],"mappings":";;;;;AAGA,MAAa,cAAc;CACzB,SAAS;CACT,YAAY;CACb;AAGD,MAAa,iBAAiB,UAC5B,OAAO,OAAO,YAAY,CAAC,SAAS,MAAqB;AAE3D,MAAa,oBAAoB,OAAO,OAAO,YAAY;AAK3D,MAAaA,WAAwC;EAClD,YAAY,UAAU;EACtB,YAAY,aAAa;CAC3B;AAED,MAAaC,mBAAgD;EAC1D,YAAY,UAAU;EACtB,YAAY,aAAa;CAC3B;AAED,MAAa,aAAa,gBAAqC;AAC7D,QAAO,SAAS;;AAGlB,MAAa,oBAAoB,gBAAqC;AACpE,QAAO,iBAAiB;;AAG1B,MAAa,uCAAgB;CAC3B,QAAQ;EACN,aAAaC,MAAE,KAAK,kBAAkB,CAAC,QAAQ,YAAY,QAAQ;EAEnE,YAAYA,MAAE,OAAO,SAAS,CAAC,QAAQ,MAAM;EAE7C,IAAIA,MAAE,OAAO,SAAS,CAAC,QAAQ,MAAM;EACtC;CAED,QAAQ,EAAE;CAEV,cAAc;CAEd,YAAY;EACV,aAAa,QAAQ,IAAI;EAEzB,YAAY,QAAQ,IAAI;EAExB,IAAI,QAAQ,IAAI;EACjB;CAED,oBAAoB,UAAU;AAE5B,UAAQ,MAAM,oCAAoC,MAAM;AACxD,QAAM,IAAI,MAAM,gCAAgC;;CAIlD,gBAAgB,QAAQ,IAAI,wBAAwB;CACrD,CAAC;;;;;;;ACzDF,MAAa,gBAAgB;AAC7B,MAAa,eAAe;AAE5B,MAAa,0BACX,SACA,UACW;AACX,yCAAyB;EACvB;EACA,SAAS;EACT;EACA,QAAQ;EACR,KAAK;EACL,WAAW;EACX,SAAS;EACV,CAAC"}
|
package/dist/context/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-
|
|
1
|
+
{"version":3,"file":"context-DK5bXjx4.cjs","names":["isServerContext"],"sources":["../src/context/asserts.ts","../src/context/helpers.ts"],"sourcesContent":["import type { OtimClientContext, OtimServerClientContext } from \"./types\";\n\nfunction isServerContext(\n context: OtimClientContext,\n): context is OtimServerClientContext {\n return \"usesApiKeyAuth\" in context;\n}\n\nexport function assertRequiresAuth(context: OtimClientContext): void {\n if (isServerContext(context) && context.usesApiKeyAuth) {\n throw new Error(\n \"Method not allowed. Api key authentication does not require user login.\",\n );\n }\n}\n\nexport function assertServerContext(\n context: OtimClientContext,\n): asserts context is OtimServerClientContext {\n if (!isServerContext(context)) {\n throw new Error(\"Method only supported in server context\");\n }\n}\n","import type { OtimClientContext, OtimServerClientContext } from \"./types\";\n\nexport const isServerContext = (\n context: OtimClientContext,\n): context is OtimServerClientContext => {\n return \"usesApiKeyAuth\" in context;\n};\n"],"mappings":";;AAEA,SAASA,kBACP,SACoC;AACpC,QAAO,oBAAoB;;AAG7B,SAAgB,mBAAmB,SAAkC;AACnE,KAAIA,kBAAgB,QAAQ,IAAI,QAAQ,eACtC,OAAM,IAAI,MACR,0EACD;;AAIL,SAAgB,oBACd,SAC4C;AAC5C,KAAI,CAACA,kBAAgB,QAAQ,CAC3B,OAAM,IAAI,MAAM,0CAA0C;;;;;AClB9D,MAAa,mBACX,YACuC;AACvC,QAAO,oBAAoB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
const require_account = require('./account-
|
|
2
|
-
const require_clients = require('./clients-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
1
|
+
const require_account = require('./account-Bwm5PTcc.cjs');
|
|
2
|
+
const require_clients = require('./clients-CeCv_iST.cjs');
|
|
3
|
+
const require_signing = require('./signing-BaJMYH0K.cjs');
|
|
4
|
+
const require_config = require('./config-BrvU6CD_.cjs');
|
|
5
|
+
const require_context = require('./context-DK5bXjx4.cjs');
|
|
6
|
+
const require_vrs = require('./vrs-Do0jfo3H.cjs');
|
|
6
7
|
|
|
7
8
|
exports.AccountType = require_account.AccountType;
|
|
8
9
|
exports.ActivityClient = require_clients.ActivityClient;
|
|
10
|
+
exports.ApiKeyClientSigningService = require_signing.ApiKeyClientSigningService;
|
|
9
11
|
exports.AuthClient = require_clients.AuthClient;
|
|
12
|
+
exports.AuthorizationDigestComputer = require_signing.AuthorizationDigestComputer;
|
|
10
13
|
exports.ConfigClient = require_clients.ConfigClient;
|
|
11
14
|
exports.DelegationClient = require_clients.DelegationClient;
|
|
12
15
|
exports.Environment = require_config.Environment;
|
|
16
|
+
exports.EthereumWalletAdapter = require_signing.EthereumWalletAdapter;
|
|
17
|
+
exports.InstructionDigestComputer = require_signing.InstructionDigestComputer;
|
|
13
18
|
exports.OrchestrationClient = require_clients.OrchestrationClient;
|
|
14
19
|
exports.SIWE_CHAIN_ID = require_config.SIWE_CHAIN_ID;
|
|
15
20
|
exports.SIWE_VERSION = require_config.SIWE_VERSION;
|
|
16
21
|
exports.ServerAccountType = require_account.ServerAccountType;
|
|
22
|
+
exports.ServerWalletSigningService = require_signing.ServerWalletSigningService;
|
|
23
|
+
exports.SignatureFormatter = require_signing.SignatureFormatter;
|
|
24
|
+
exports.UnifiedPaymentSigner = require_signing.UnifiedPaymentSigner;
|
|
17
25
|
exports.assertRequiresAuth = require_context.assertRequiresAuth;
|
|
18
26
|
exports.assertServerContext = require_context.assertServerContext;
|
|
19
27
|
exports.createClientContext = require_account.createClientContext;
|
|
20
|
-
exports.createEIP2098Signature =
|
|
28
|
+
exports.createEIP2098Signature = require_vrs.createEIP2098Signature;
|
|
21
29
|
exports.createLoginSiweMessage = require_config.createLoginSiweMessage;
|
|
22
|
-
exports.createRlpEncodedAuthorization =
|
|
30
|
+
exports.createRlpEncodedAuthorization = require_signing.createRlpEncodedAuthorization;
|
|
31
|
+
exports.createSettlementSigner = require_clients.createSettlementSigner;
|
|
23
32
|
exports.env = require_config.env;
|
|
24
33
|
exports.getApiUrl = require_config.getApiUrl;
|
|
25
34
|
exports.getTurnkeyApiUrl = require_config.getTurnkeyApiUrl;
|
|
@@ -27,6 +36,6 @@ exports.isApiAccountConfig = require_account.isApiAccountConfig;
|
|
|
27
36
|
exports.isEnvironment = require_config.isEnvironment;
|
|
28
37
|
exports.isPrivateKeyAccountConfig = require_account.isPrivateKeyAccountConfig;
|
|
29
38
|
exports.isServerContext = require_context.isServerContext;
|
|
30
|
-
exports.normalizeYParityValue =
|
|
31
|
-
exports.parseSignatureToVRS =
|
|
39
|
+
exports.normalizeYParityValue = require_vrs.normalizeYParityValue;
|
|
40
|
+
exports.parseSignatureToVRS = require_vrs.parseSignatureToVRS;
|
|
32
41
|
exports.prepareSettlement = require_clients.prepareSettlement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_signing = require('../signing-BaJMYH0K.cjs');
|
|
2
|
+
|
|
3
|
+
exports.ApiKeyClientSigningService = require_signing.ApiKeyClientSigningService;
|
|
4
|
+
exports.AuthorizationDigestComputer = require_signing.AuthorizationDigestComputer;
|
|
5
|
+
exports.EthereumWalletAdapter = require_signing.EthereumWalletAdapter;
|
|
6
|
+
exports.InstructionDigestComputer = require_signing.InstructionDigestComputer;
|
|
7
|
+
exports.ServerWalletSigningService = require_signing.ServerWalletSigningService;
|
|
8
|
+
exports.SignatureFormatter = require_signing.SignatureFormatter;
|
|
9
|
+
exports.UnifiedPaymentSigner = require_signing.UnifiedPaymentSigner;
|
|
10
|
+
exports.createRlpEncodedAuthorization = require_signing.createRlpEncodedAuthorization;
|