@openfort/openfort-node 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +559 -582
- package/dist/index.d.ts +559 -582
- package/dist/index.js +539 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +538 -182
- package/dist/index.mjs.map +1 -1
- package/examples/evm/delegation/sendTransaction.ts +34 -0
- package/examples/evm/policies/createAccountPolicy.ts +68 -0
- package/examples/evm/policies/createProjectPolicy.ts +53 -0
- package/examples/evm/policies/deletePolicy.ts +34 -0
- package/examples/evm/policies/getPolicyById.ts +34 -0
- package/examples/evm/policies/listAccountPolicies.ts +11 -0
- package/examples/evm/policies/listPolicies.ts +11 -0
- package/examples/evm/policies/listProjectPolicies.ts +11 -0
- package/examples/evm/policies/signTypedDataPolicy.ts +35 -0
- package/examples/evm/policies/updatePolicy.ts +44 -0
- package/examples/evm/policies/validation.ts +45 -0
- package/examples/evm/transactions/sendTransaction.ts +44 -0
- package/examples/package.json +13 -0
- package/examples/pnpm-lock.yaml +933 -0
- package/examples/solana/policies/createSolAllowlistPolicy.ts +27 -0
- package/examples/solana/policies/createSolMessagePolicy.ts +29 -0
- package/examples/solana/policies/createSplTokenLimitsPolicy.ts +33 -0
- package/examples/solana/transactions/sendRawTransaction.ts +23 -0
- package/examples/solana/transactions/sendTransaction.ts +37 -0
- package/examples/solana/transactions/transfer.ts +44 -0
- package/knip.json +10 -1
- package/openapi.json +28 -637
- package/package.json +42 -4
- package/tsconfig.json +3 -4
- package/examples/policies/createAccountPolicy.ts +0 -71
- package/examples/policies/createEvmPolicy.ts +0 -149
- package/examples/policies/createSolanaPolicy.ts +0 -176
- package/examples/policies/createTypedDataPolicy.ts +0 -159
- package/examples/policies/deletePolicy.ts +0 -34
- package/examples/policies/getPolicy.ts +0 -41
- package/examples/policies/listPolicies.ts +0 -34
- package/examples/policies/multiRulePolicy.ts +0 -133
- package/examples/policies/updatePolicy.ts +0 -77
- package/examples/policies/validatePolicy.ts +0 -176
- /package/examples/{contracts → evm/contracts}/createContract.ts +0 -0
- /package/examples/{contracts → evm/contracts}/listContracts.ts +0 -0
- /package/examples/{transactions → evm/transactionIntents}/createTransactionIntent.ts +0 -0
- /package/examples/{transactions → evm/transactionIntents}/estimateGas.ts +0 -0
- /package/examples/{transactions → evm/transactionIntents}/getTransactionIntent.ts +0 -0
- /package/examples/{transactions → evm/transactionIntents}/listTransactionIntents.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -50,11 +50,6 @@ __export(index_exports, {
|
|
|
50
50
|
AuthProviderResponseV2: () => AuthProviderResponseV2,
|
|
51
51
|
AuthenticateOAuthRequestProvider: () => AuthenticateOAuthRequestProvider,
|
|
52
52
|
AuthenticationType: () => AuthenticationType,
|
|
53
|
-
BackendWalletListQueriesChainType: () => BackendWalletListQueriesChainType,
|
|
54
|
-
BackendWalletListResponseObject: () => BackendWalletListResponseObject,
|
|
55
|
-
BackendWalletResponseChainType: () => BackendWalletResponseChainType,
|
|
56
|
-
BackendWalletResponseCustody: () => BackendWalletResponseCustody,
|
|
57
|
-
BackendWalletResponseObject: () => BackendWalletResponseObject,
|
|
58
53
|
BasicAuthProvider: () => BasicAuthProvider,
|
|
59
54
|
BasicAuthProviderEMAIL: () => BasicAuthProviderEMAIL,
|
|
60
55
|
BasicAuthProviderGUEST: () => BasicAuthProviderGUEST,
|
|
@@ -82,6 +77,7 @@ __export(index_exports, {
|
|
|
82
77
|
CriteriaOperatorNOTIN: () => CriteriaOperatorNOTIN,
|
|
83
78
|
CriteriaType: () => CriteriaType,
|
|
84
79
|
Currency: () => Currency,
|
|
80
|
+
DelegationError: () => DelegationError,
|
|
85
81
|
DeleteBackendWalletResponseObject: () => DeleteBackendWalletResponseObject,
|
|
86
82
|
DeveloperAccountResponseExpandable: () => DeveloperAccountResponseExpandable,
|
|
87
83
|
EmailTypeRequest: () => EmailTypeRequest,
|
|
@@ -166,7 +162,6 @@ __export(index_exports, {
|
|
|
166
162
|
JsonRpcErrorResponseJsonrpc: () => JsonRpcErrorResponseJsonrpc,
|
|
167
163
|
JsonRpcRequestJsonrpc: () => JsonRpcRequestJsonrpc,
|
|
168
164
|
JsonRpcSuccessResponseAnyJsonrpc: () => JsonRpcSuccessResponseAnyJsonrpc,
|
|
169
|
-
ListBackendWalletsChainType: () => ListBackendWalletsChainType,
|
|
170
165
|
ListPoliciesScopeItem: () => ListPoliciesScopeItem,
|
|
171
166
|
MintAddressCriterionOperator: () => MintAddressCriterionOperator,
|
|
172
167
|
MintAddressCriterionRequestOperator: () => MintAddressCriterionRequestOperator,
|
|
@@ -296,12 +291,6 @@ __export(index_exports, {
|
|
|
296
291
|
TransactionIntentResponseExpandable: () => TransactionIntentResponseExpandable,
|
|
297
292
|
TransactionStatus: () => TransactionStatus,
|
|
298
293
|
UnknownError: () => UnknownError,
|
|
299
|
-
UpdateBackendWalletRequestAccountType: () => UpdateBackendWalletRequestAccountType,
|
|
300
|
-
UpdateBackendWalletRequestChainType: () => UpdateBackendWalletRequestChainType,
|
|
301
|
-
UpdateBackendWalletResponseChainType: () => UpdateBackendWalletResponseChainType,
|
|
302
|
-
UpdateBackendWalletResponseCustody: () => UpdateBackendWalletResponseCustody,
|
|
303
|
-
UpdateBackendWalletResponseDelegatedAccountChainChainType: () => UpdateBackendWalletResponseDelegatedAccountChainChainType,
|
|
304
|
-
UpdateBackendWalletResponseObject: () => UpdateBackendWalletResponseObject,
|
|
305
294
|
UpdatePolicyBodySchema: () => UpdatePolicyBodySchema,
|
|
306
295
|
UsageAlertType: () => UsageAlertType,
|
|
307
296
|
UserInputValidationError: () => UserInputValidationError,
|
|
@@ -314,7 +303,6 @@ __export(index_exports, {
|
|
|
314
303
|
authApi: () => auth_v2_exports,
|
|
315
304
|
authSchemas: () => openfortAuth_schemas_exports,
|
|
316
305
|
authenticateSIWE: () => authenticateSIWE,
|
|
317
|
-
authorize: () => authorize,
|
|
318
306
|
callbackOAuth: () => callbackOAuth,
|
|
319
307
|
cancelTransferAccountOwnership: () => cancelTransferAccountOwnership,
|
|
320
308
|
configure: () => configure,
|
|
@@ -377,7 +365,6 @@ __export(index_exports, {
|
|
|
377
365
|
getAuthPlayers: () => getAuthPlayers,
|
|
378
366
|
getAuthUser: () => getAuthUser,
|
|
379
367
|
getAuthUsers: () => getAuthUsers,
|
|
380
|
-
getBackendWallet: () => getBackendWallet,
|
|
381
368
|
getConfig: () => getConfig,
|
|
382
369
|
getContract: () => getContract,
|
|
383
370
|
getContracts: () => getContracts,
|
|
@@ -426,7 +413,6 @@ __export(index_exports, {
|
|
|
426
413
|
linkSIWE: () => linkSIWE,
|
|
427
414
|
linkThirdParty: () => linkThirdParty,
|
|
428
415
|
list: () => list,
|
|
429
|
-
listBackendWallets: () => listBackendWallets,
|
|
430
416
|
listFeeSponsorships: () => listFeeSponsorships,
|
|
431
417
|
listForwarderContracts: () => listForwarderContracts,
|
|
432
418
|
listOAuthConfig: () => listOAuthConfig,
|
|
@@ -434,7 +420,6 @@ __export(index_exports, {
|
|
|
434
420
|
listPolicies: () => listPolicies,
|
|
435
421
|
listSubscriptionLogs: () => listSubscriptionLogs,
|
|
436
422
|
loginEmailPassword: () => loginEmailPassword,
|
|
437
|
-
loginOIDC: () => loginOIDC,
|
|
438
423
|
loginWithIdToken: () => loginWithIdToken,
|
|
439
424
|
logout: () => logout,
|
|
440
425
|
me: () => me,
|
|
@@ -468,7 +453,6 @@ __export(index_exports, {
|
|
|
468
453
|
unlinkEmail: () => unlinkEmail,
|
|
469
454
|
unlinkOAuth: () => unlinkOAuth,
|
|
470
455
|
unlinkSIWE: () => unlinkSIWE,
|
|
471
|
-
updateBackendWallet: () => updateBackendWallet,
|
|
472
456
|
updateContract: () => updateContract,
|
|
473
457
|
updateDeveloperAccount: () => updateDeveloperAccount,
|
|
474
458
|
updateFeeSponsorship: () => updateFeeSponsorship,
|
|
@@ -666,6 +650,15 @@ var AccountNotFoundError = class _AccountNotFoundError extends Error {
|
|
|
666
650
|
}
|
|
667
651
|
}
|
|
668
652
|
};
|
|
653
|
+
var DelegationError = class _DelegationError extends Error {
|
|
654
|
+
constructor(message) {
|
|
655
|
+
super(message);
|
|
656
|
+
this.name = "DelegationError";
|
|
657
|
+
if (Error.captureStackTrace) {
|
|
658
|
+
Error.captureStackTrace(this, _DelegationError);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
};
|
|
669
662
|
var EncryptionError = class _EncryptionError extends Error {
|
|
670
663
|
/**
|
|
671
664
|
* Initializes a new EncryptionError instance.
|
|
@@ -849,7 +842,7 @@ function requiresWalletAuth(requestMethod, requestPath) {
|
|
|
849
842
|
}
|
|
850
843
|
|
|
851
844
|
// src/version.ts
|
|
852
|
-
var VERSION = "0.
|
|
845
|
+
var VERSION = "0.10.0";
|
|
853
846
|
var PACKAGE = "@openfort/openfort-node";
|
|
854
847
|
|
|
855
848
|
// src/openapi-client/openfortApiClient.ts
|
|
@@ -1453,17 +1446,6 @@ var verifyAuthToken = (params, options) => {
|
|
|
1453
1446
|
options
|
|
1454
1447
|
);
|
|
1455
1448
|
};
|
|
1456
|
-
var authorize = (authorizePlayerRequest, options) => {
|
|
1457
|
-
return openfortApiClient(
|
|
1458
|
-
{
|
|
1459
|
-
url: `/iam/v1/authorize`,
|
|
1460
|
-
method: "POST",
|
|
1461
|
-
headers: { "Content-Type": "application/json" },
|
|
1462
|
-
data: authorizePlayerRequest
|
|
1463
|
-
},
|
|
1464
|
-
options
|
|
1465
|
-
);
|
|
1466
|
-
};
|
|
1467
1449
|
|
|
1468
1450
|
// src/openapi-client/generated/auth/auth-v2/auth-v2.ts
|
|
1469
1451
|
var auth_v2_exports = {};
|
|
@@ -2151,17 +2133,6 @@ var unlinkEmail = (unlinkEmailRequest, options) => {
|
|
|
2151
2133
|
options
|
|
2152
2134
|
);
|
|
2153
2135
|
};
|
|
2154
|
-
var loginOIDC = (loginOIDCRequest, options) => {
|
|
2155
|
-
return openfortApiClient(
|
|
2156
|
-
{
|
|
2157
|
-
url: `/iam/v1/oidc/login`,
|
|
2158
|
-
method: "POST",
|
|
2159
|
-
headers: { "Content-Type": "application/json" },
|
|
2160
|
-
data: loginOIDCRequest
|
|
2161
|
-
},
|
|
2162
|
-
options
|
|
2163
|
-
);
|
|
2164
|
-
};
|
|
2165
2136
|
var initOAuth = (oAuthInitRequest, options) => {
|
|
2166
2137
|
return openfortApiClient(
|
|
2167
2138
|
{
|
|
@@ -2267,16 +2238,6 @@ var me = (options) => {
|
|
|
2267
2238
|
};
|
|
2268
2239
|
|
|
2269
2240
|
// src/openapi-client/generated/backend-wallets/backend-wallets.ts
|
|
2270
|
-
var listBackendWallets = (params, options) => {
|
|
2271
|
-
return openfortApiClient(
|
|
2272
|
-
{
|
|
2273
|
-
url: `/v2/accounts/backend`,
|
|
2274
|
-
method: "GET",
|
|
2275
|
-
params
|
|
2276
|
-
},
|
|
2277
|
-
options
|
|
2278
|
-
);
|
|
2279
|
-
};
|
|
2280
2241
|
var createBackendWallet = (createBackendWalletRequest, options) => {
|
|
2281
2242
|
return openfortApiClient(
|
|
2282
2243
|
{
|
|
@@ -2288,26 +2249,6 @@ var createBackendWallet = (createBackendWalletRequest, options) => {
|
|
|
2288
2249
|
options
|
|
2289
2250
|
);
|
|
2290
2251
|
};
|
|
2291
|
-
var getBackendWallet = (id, options) => {
|
|
2292
|
-
return openfortApiClient(
|
|
2293
|
-
{
|
|
2294
|
-
url: `/v2/accounts/backend/${id}`,
|
|
2295
|
-
method: "GET"
|
|
2296
|
-
},
|
|
2297
|
-
options
|
|
2298
|
-
);
|
|
2299
|
-
};
|
|
2300
|
-
var updateBackendWallet = (id, updateBackendWalletRequest, options) => {
|
|
2301
|
-
return openfortApiClient(
|
|
2302
|
-
{
|
|
2303
|
-
url: `/v2/accounts/backend/${id}`,
|
|
2304
|
-
method: "PUT",
|
|
2305
|
-
headers: { "Content-Type": "application/json" },
|
|
2306
|
-
data: updateBackendWalletRequest
|
|
2307
|
-
},
|
|
2308
|
-
options
|
|
2309
|
-
);
|
|
2310
|
-
};
|
|
2311
2252
|
var deleteBackendWallet = (id, options) => {
|
|
2312
2253
|
return openfortApiClient(
|
|
2313
2254
|
{
|
|
@@ -3367,23 +3308,6 @@ var CreateEmbeddedRequestChainType = {
|
|
|
3367
3308
|
EVM: "EVM",
|
|
3368
3309
|
SVM: "SVM"
|
|
3369
3310
|
};
|
|
3370
|
-
var BackendWalletResponseObject = {
|
|
3371
|
-
backendWallet: "backendWallet"
|
|
3372
|
-
};
|
|
3373
|
-
var BackendWalletResponseChainType = {
|
|
3374
|
-
EVM: "EVM",
|
|
3375
|
-
SVM: "SVM"
|
|
3376
|
-
};
|
|
3377
|
-
var BackendWalletResponseCustody = {
|
|
3378
|
-
Developer: "Developer"
|
|
3379
|
-
};
|
|
3380
|
-
var BackendWalletListResponseObject = {
|
|
3381
|
-
list: "list"
|
|
3382
|
-
};
|
|
3383
|
-
var BackendWalletListQueriesChainType = {
|
|
3384
|
-
EVM: "EVM",
|
|
3385
|
-
SVM: "SVM"
|
|
3386
|
-
};
|
|
3387
3311
|
var CreateBackendWalletResponseObject = {
|
|
3388
3312
|
account: "account"
|
|
3389
3313
|
};
|
|
@@ -3395,27 +3319,6 @@ var CreateBackendWalletRequestChainType = {
|
|
|
3395
3319
|
EVM: "EVM",
|
|
3396
3320
|
SVM: "SVM"
|
|
3397
3321
|
};
|
|
3398
|
-
var UpdateBackendWalletResponseObject = {
|
|
3399
|
-
backendWallet: "backendWallet"
|
|
3400
|
-
};
|
|
3401
|
-
var UpdateBackendWalletResponseChainType = {
|
|
3402
|
-
EVM: "EVM",
|
|
3403
|
-
SVM: "SVM"
|
|
3404
|
-
};
|
|
3405
|
-
var UpdateBackendWalletResponseCustody = {
|
|
3406
|
-
Developer: "Developer"
|
|
3407
|
-
};
|
|
3408
|
-
var UpdateBackendWalletResponseDelegatedAccountChainChainType = {
|
|
3409
|
-
EVM: "EVM",
|
|
3410
|
-
SVM: "SVM"
|
|
3411
|
-
};
|
|
3412
|
-
var UpdateBackendWalletRequestAccountType = {
|
|
3413
|
-
Delegated_Account: "Delegated Account"
|
|
3414
|
-
};
|
|
3415
|
-
var UpdateBackendWalletRequestChainType = {
|
|
3416
|
-
EVM: "EVM",
|
|
3417
|
-
SVM: "SVM"
|
|
3418
|
-
};
|
|
3419
3322
|
var DeleteBackendWalletResponseObject = {
|
|
3420
3323
|
backendWallet: "backendWallet"
|
|
3421
3324
|
};
|
|
@@ -3670,10 +3573,6 @@ var ListPoliciesScopeItem = {
|
|
|
3670
3573
|
account: "account",
|
|
3671
3574
|
transaction: "transaction"
|
|
3672
3575
|
};
|
|
3673
|
-
var ListBackendWalletsChainType = {
|
|
3674
|
-
EVM: "EVM",
|
|
3675
|
-
SVM: "SVM"
|
|
3676
|
-
};
|
|
3677
3576
|
var GetAccountsV2ChainType = {
|
|
3678
3577
|
EVM: "EVM",
|
|
3679
3578
|
SVM: "SVM"
|
|
@@ -4339,9 +4238,6 @@ var decryptExportedPrivateKey = (encryptedPrivateKeyBase64, privateKeyPem) => {
|
|
|
4339
4238
|
return decrypted.toString("hex");
|
|
4340
4239
|
};
|
|
4341
4240
|
|
|
4342
|
-
// src/wallets/evm/accounts/evmAccount.ts
|
|
4343
|
-
var import_viem = require("viem");
|
|
4344
|
-
|
|
4345
4241
|
// src/wallets/evm/actions/normalizeSignature.ts
|
|
4346
4242
|
function normalizeSignature(sig) {
|
|
4347
4243
|
const v = parseInt(sig.slice(-2), 16);
|
|
@@ -4363,11 +4259,12 @@ async function signHash(options) {
|
|
|
4363
4259
|
|
|
4364
4260
|
// src/wallets/evm/accounts/evmAccount.ts
|
|
4365
4261
|
function toEvmAccount(data) {
|
|
4366
|
-
const { id, address } = data;
|
|
4262
|
+
const { id, address, walletId } = data;
|
|
4367
4263
|
const account = {
|
|
4368
4264
|
id,
|
|
4369
4265
|
address,
|
|
4370
4266
|
custody: "Developer",
|
|
4267
|
+
walletId,
|
|
4371
4268
|
async sign(parameters) {
|
|
4372
4269
|
const result = await signHash({
|
|
4373
4270
|
accountId: id,
|
|
@@ -4376,29 +4273,53 @@ function toEvmAccount(data) {
|
|
|
4376
4273
|
return result.signature;
|
|
4377
4274
|
},
|
|
4378
4275
|
async signMessage(parameters) {
|
|
4276
|
+
let viem;
|
|
4277
|
+
try {
|
|
4278
|
+
viem = await import("viem");
|
|
4279
|
+
} catch {
|
|
4280
|
+
throw new UserInputValidationError(
|
|
4281
|
+
"`viem` is required for signMessage. Install it and try again."
|
|
4282
|
+
);
|
|
4283
|
+
}
|
|
4379
4284
|
const { message } = parameters;
|
|
4380
|
-
const preimage =
|
|
4285
|
+
const preimage = viem.toPrefixedMessage(message);
|
|
4381
4286
|
const result = await sign(id, { data: preimage });
|
|
4382
|
-
return result.signature;
|
|
4287
|
+
return normalizeSignature(result.signature);
|
|
4383
4288
|
},
|
|
4384
4289
|
async signTransaction(transaction) {
|
|
4385
|
-
|
|
4290
|
+
let viem;
|
|
4291
|
+
try {
|
|
4292
|
+
viem = await import("viem");
|
|
4293
|
+
} catch {
|
|
4294
|
+
throw new UserInputValidationError(
|
|
4295
|
+
"`viem` is required for signTransaction. Install it and try again."
|
|
4296
|
+
);
|
|
4297
|
+
}
|
|
4298
|
+
const serialized = viem.serializeTransaction(transaction);
|
|
4386
4299
|
const response = await sign(id, { data: serialized });
|
|
4387
|
-
const signature2 =
|
|
4388
|
-
const signedTransaction =
|
|
4300
|
+
const signature2 = viem.parseSignature(response.signature);
|
|
4301
|
+
const signedTransaction = viem.serializeTransaction(
|
|
4389
4302
|
transaction,
|
|
4390
4303
|
signature2
|
|
4391
4304
|
);
|
|
4392
4305
|
return signedTransaction;
|
|
4393
4306
|
},
|
|
4394
4307
|
async signTypedData(parameters) {
|
|
4308
|
+
let viem;
|
|
4309
|
+
try {
|
|
4310
|
+
viem = await import("viem");
|
|
4311
|
+
} catch {
|
|
4312
|
+
throw new UserInputValidationError(
|
|
4313
|
+
"`viem` is required for signTypedData. Install it and try again."
|
|
4314
|
+
);
|
|
4315
|
+
}
|
|
4395
4316
|
const {
|
|
4396
4317
|
domain = {},
|
|
4397
4318
|
message,
|
|
4398
4319
|
primaryType
|
|
4399
4320
|
} = parameters;
|
|
4400
4321
|
const types = {
|
|
4401
|
-
EIP712Domain:
|
|
4322
|
+
EIP712Domain: viem.getTypesForEIP712Domain({ domain }),
|
|
4402
4323
|
...parameters.types
|
|
4403
4324
|
};
|
|
4404
4325
|
const openApiMessage = {
|
|
@@ -4407,9 +4328,9 @@ function toEvmAccount(data) {
|
|
|
4407
4328
|
primaryType,
|
|
4408
4329
|
message
|
|
4409
4330
|
};
|
|
4410
|
-
const hash =
|
|
4331
|
+
const hash = viem.hashTypedData(openApiMessage);
|
|
4411
4332
|
const result = await sign(id, { data: hash });
|
|
4412
|
-
return result.signature;
|
|
4333
|
+
return normalizeSignature(result.signature);
|
|
4413
4334
|
}
|
|
4414
4335
|
};
|
|
4415
4336
|
return account;
|
|
@@ -4419,7 +4340,8 @@ function toEvmAccount(data) {
|
|
|
4419
4340
|
function toEvmAccountData(response) {
|
|
4420
4341
|
return {
|
|
4421
4342
|
id: response.id,
|
|
4422
|
-
address: response.address
|
|
4343
|
+
address: response.address,
|
|
4344
|
+
walletId: response.wallet
|
|
4423
4345
|
};
|
|
4424
4346
|
}
|
|
4425
4347
|
var EvmClient = class {
|
|
@@ -4459,7 +4381,8 @@ var EvmClient = class {
|
|
|
4459
4381
|
});
|
|
4460
4382
|
return toEvmAccount({
|
|
4461
4383
|
id: response.id,
|
|
4462
|
-
address: response.address
|
|
4384
|
+
address: response.address,
|
|
4385
|
+
walletId: response.walletId
|
|
4463
4386
|
});
|
|
4464
4387
|
}
|
|
4465
4388
|
/**
|
|
@@ -4487,13 +4410,17 @@ var EvmClient = class {
|
|
|
4487
4410
|
);
|
|
4488
4411
|
}
|
|
4489
4412
|
if (options.id) {
|
|
4490
|
-
const response = await
|
|
4413
|
+
const response = await getAccountV2(options.id);
|
|
4414
|
+
if (response.custody !== "Developer") {
|
|
4415
|
+
throw new AccountNotFoundError();
|
|
4416
|
+
}
|
|
4491
4417
|
return toEvmAccount(toEvmAccountData(response));
|
|
4492
4418
|
}
|
|
4493
4419
|
if (options.address) {
|
|
4494
|
-
const wallets = await
|
|
4420
|
+
const wallets = await getAccountsV2({
|
|
4495
4421
|
address: options.address,
|
|
4496
4422
|
chainType: "EVM",
|
|
4423
|
+
custody: "Developer",
|
|
4497
4424
|
limit: 1
|
|
4498
4425
|
});
|
|
4499
4426
|
if (wallets.data.length === 0) {
|
|
@@ -4503,6 +4430,21 @@ var EvmClient = class {
|
|
|
4503
4430
|
}
|
|
4504
4431
|
throw new AccountNotFoundError();
|
|
4505
4432
|
}
|
|
4433
|
+
/**
|
|
4434
|
+
* Retrieves delegated accounts linked to an EVM address on a specific chain.
|
|
4435
|
+
*
|
|
4436
|
+
* @param options - Options containing the address and chain ID
|
|
4437
|
+
* @returns List of linked accounts
|
|
4438
|
+
*/
|
|
4439
|
+
async getLinkedAccounts(options) {
|
|
4440
|
+
const response = await getAccountsV2({
|
|
4441
|
+
address: options.address,
|
|
4442
|
+
accountType: "Delegated Account",
|
|
4443
|
+
chainType: "EVM",
|
|
4444
|
+
chainId: options.chainId
|
|
4445
|
+
});
|
|
4446
|
+
return response;
|
|
4447
|
+
}
|
|
4506
4448
|
/**
|
|
4507
4449
|
* Lists all EVM backend wallets.
|
|
4508
4450
|
*
|
|
@@ -4517,10 +4459,11 @@ var EvmClient = class {
|
|
|
4517
4459
|
* ```
|
|
4518
4460
|
*/
|
|
4519
4461
|
async listAccounts(options = {}) {
|
|
4520
|
-
const response = await
|
|
4462
|
+
const response = await getAccountsV2({
|
|
4521
4463
|
limit: options.limit,
|
|
4522
4464
|
skip: options.skip,
|
|
4523
|
-
chainType: "EVM"
|
|
4465
|
+
chainType: "EVM",
|
|
4466
|
+
custody: "Developer"
|
|
4524
4467
|
});
|
|
4525
4468
|
const accounts = response.data.map(
|
|
4526
4469
|
(wallet) => toEvmAccount(toEvmAccountData(wallet))
|
|
@@ -4567,7 +4510,8 @@ var EvmClient = class {
|
|
|
4567
4510
|
});
|
|
4568
4511
|
return toEvmAccount({
|
|
4569
4512
|
id: response.id,
|
|
4570
|
-
address: response.address
|
|
4513
|
+
address: response.address,
|
|
4514
|
+
walletId: response.walletId
|
|
4571
4515
|
});
|
|
4572
4516
|
} catch (error) {
|
|
4573
4517
|
if (error instanceof UserInputValidationError) {
|
|
@@ -4624,34 +4568,204 @@ var EvmClient = class {
|
|
|
4624
4568
|
});
|
|
4625
4569
|
return response.signature;
|
|
4626
4570
|
}
|
|
4627
|
-
/**
|
|
4628
|
-
* Updates an EVM backend wallet.
|
|
4629
|
-
*
|
|
4630
|
-
* Currently supports upgrading an EVM EOA to a Delegated Account (EIP-7702).
|
|
4631
|
-
*
|
|
4632
|
-
* @param options - Update options including account ID and delegation parameters
|
|
4633
|
-
* @returns The updated backend wallet response
|
|
4634
|
-
*
|
|
4635
|
-
* @example
|
|
4636
|
-
* ```typescript
|
|
4637
|
-
* const updated = await openfort.accounts.evm.backend.update({
|
|
4638
|
-
* id: 'acc_...',
|
|
4639
|
-
* accountType: 'Delegated Account',
|
|
4640
|
-
* chain: { chainType: 'EVM', chainId: 8453 },
|
|
4641
|
-
* implementationType: 'Calibur',
|
|
4642
|
-
* });
|
|
4643
|
-
* ```
|
|
4644
|
-
*/
|
|
4645
|
-
async update(options) {
|
|
4646
|
-
const { id, ...req } = options;
|
|
4647
|
-
return updateBackendWallet(id, req);
|
|
4648
|
-
}
|
|
4649
4571
|
};
|
|
4650
4572
|
EvmClient.type = "evmWallet";
|
|
4651
4573
|
|
|
4652
4574
|
// src/wallets/solana/solanaClient.ts
|
|
4653
4575
|
var import_bs58 = __toESM(require("bs58"));
|
|
4654
4576
|
|
|
4577
|
+
// src/wallets/solana/actions/constants.ts
|
|
4578
|
+
var USDC_MAINNET_MINT_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
4579
|
+
var USDC_DEVNET_MINT_ADDRESS = "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
|
|
4580
|
+
var DEFAULT_COMPUTE_UNIT_LIMIT = 2e5;
|
|
4581
|
+
var DEFAULT_COMPUTE_UNIT_PRICE = 50000n;
|
|
4582
|
+
|
|
4583
|
+
// src/wallets/solana/actions/utils.ts
|
|
4584
|
+
function getUsdcMintAddress(cluster) {
|
|
4585
|
+
if (cluster === "mainnet-beta") {
|
|
4586
|
+
return USDC_MAINNET_MINT_ADDRESS;
|
|
4587
|
+
}
|
|
4588
|
+
return USDC_DEVNET_MINT_ADDRESS;
|
|
4589
|
+
}
|
|
4590
|
+
function getRpcEndpoint(cluster) {
|
|
4591
|
+
return cluster === "mainnet-beta" ? "https://api.mainnet-beta.solana.com" : "https://api.devnet.solana.com";
|
|
4592
|
+
}
|
|
4593
|
+
function getWsEndpoint(cluster) {
|
|
4594
|
+
return cluster === "mainnet-beta" ? "wss://api.mainnet-beta.solana.com" : "wss://api.devnet.solana.com";
|
|
4595
|
+
}
|
|
4596
|
+
|
|
4597
|
+
// src/wallets/solana/actions/sendTransaction.ts
|
|
4598
|
+
async function sendTransaction(options) {
|
|
4599
|
+
const {
|
|
4600
|
+
account,
|
|
4601
|
+
cluster,
|
|
4602
|
+
instructions,
|
|
4603
|
+
computeUnitLimit,
|
|
4604
|
+
computeUnitPrice,
|
|
4605
|
+
rpcUrl,
|
|
4606
|
+
wsUrl
|
|
4607
|
+
} = options;
|
|
4608
|
+
let solanaKit;
|
|
4609
|
+
let computeBudget;
|
|
4610
|
+
let transactionConfirmation;
|
|
4611
|
+
let koraModule;
|
|
4612
|
+
try {
|
|
4613
|
+
solanaKit = await import("@solana/kit");
|
|
4614
|
+
} catch {
|
|
4615
|
+
throw new UserInputValidationError(
|
|
4616
|
+
"`@solana/kit` is required for sendTransaction. Install it and try again."
|
|
4617
|
+
);
|
|
4618
|
+
}
|
|
4619
|
+
try {
|
|
4620
|
+
computeBudget = await import("@solana-program/compute-budget");
|
|
4621
|
+
} catch {
|
|
4622
|
+
throw new UserInputValidationError(
|
|
4623
|
+
"`@solana-program/compute-budget` is required for sendTransaction. Install it and try again."
|
|
4624
|
+
);
|
|
4625
|
+
}
|
|
4626
|
+
try {
|
|
4627
|
+
koraModule = await import("@solana/kora");
|
|
4628
|
+
} catch {
|
|
4629
|
+
throw new UserInputValidationError(
|
|
4630
|
+
"`@solana/kora` is required for sendTransaction. Install it and try again."
|
|
4631
|
+
);
|
|
4632
|
+
}
|
|
4633
|
+
try {
|
|
4634
|
+
transactionConfirmation = await import("@solana/transaction-confirmation");
|
|
4635
|
+
} catch {
|
|
4636
|
+
throw new UserInputValidationError(
|
|
4637
|
+
"`@solana/transaction-confirmation` is required for sendTransaction. Install it and try again."
|
|
4638
|
+
);
|
|
4639
|
+
}
|
|
4640
|
+
const userAddress = solanaKit.address(account.address);
|
|
4641
|
+
const clientConfig2 = getConfig();
|
|
4642
|
+
if (!clientConfig2?.publishableKey) {
|
|
4643
|
+
throw new MissingPublishableKeyError("sendTransaction");
|
|
4644
|
+
}
|
|
4645
|
+
const basePath = clientConfig2.basePath || "https://api.openfort.io";
|
|
4646
|
+
const client = new koraModule.KoraClient({
|
|
4647
|
+
rpcUrl: `${basePath}/rpc/solana/${cluster}`,
|
|
4648
|
+
apiKey: `Bearer ${clientConfig2.publishableKey}`
|
|
4649
|
+
});
|
|
4650
|
+
const rpc = solanaKit.createSolanaRpc(rpcUrl ?? getRpcEndpoint(cluster));
|
|
4651
|
+
const rpcSubscriptions = solanaKit.createSolanaRpcSubscriptions(
|
|
4652
|
+
wsUrl ?? getWsEndpoint(cluster)
|
|
4653
|
+
);
|
|
4654
|
+
const confirmTransaction = transactionConfirmation.createRecentSignatureConfirmationPromiseFactory({
|
|
4655
|
+
rpc,
|
|
4656
|
+
rpcSubscriptions
|
|
4657
|
+
});
|
|
4658
|
+
const { signer_address } = await client.getPayerSigner();
|
|
4659
|
+
const blockhashResponse = await client.getBlockhash();
|
|
4660
|
+
let txMsg = solanaKit.pipe(
|
|
4661
|
+
solanaKit.createTransactionMessage({ version: 0 }),
|
|
4662
|
+
(tx) => solanaKit.setTransactionMessageFeePayer(
|
|
4663
|
+
solanaKit.address(signer_address),
|
|
4664
|
+
tx
|
|
4665
|
+
),
|
|
4666
|
+
// Kora's getBlockhash does not return lastValidBlockHeight, so we use 0n.
|
|
4667
|
+
// Transaction expiry is handled by the confirmTransaction timeout instead.
|
|
4668
|
+
(tx) => solanaKit.setTransactionMessageLifetimeUsingBlockhash(
|
|
4669
|
+
{
|
|
4670
|
+
blockhash: blockhashResponse.blockhash,
|
|
4671
|
+
lastValidBlockHeight: 0n
|
|
4672
|
+
},
|
|
4673
|
+
tx
|
|
4674
|
+
),
|
|
4675
|
+
(tx) => solanaKit.appendTransactionMessageInstructions(instructions, tx),
|
|
4676
|
+
(tx) => computeBudget.updateOrAppendSetComputeUnitPriceInstruction(
|
|
4677
|
+
computeUnitPrice ?? DEFAULT_COMPUTE_UNIT_PRICE,
|
|
4678
|
+
tx
|
|
4679
|
+
),
|
|
4680
|
+
(tx) => computeBudget.updateOrAppendSetComputeUnitLimitInstruction(
|
|
4681
|
+
computeUnitLimit ?? DEFAULT_COMPUTE_UNIT_LIMIT,
|
|
4682
|
+
tx
|
|
4683
|
+
)
|
|
4684
|
+
);
|
|
4685
|
+
if (computeUnitLimit === void 0) {
|
|
4686
|
+
const estimateComputeUnitLimit = computeBudget.estimateComputeUnitLimitFactory({ rpc });
|
|
4687
|
+
try {
|
|
4688
|
+
const estimatedLimit = await estimateComputeUnitLimit(txMsg);
|
|
4689
|
+
txMsg = computeBudget.updateOrAppendSetComputeUnitLimitInstruction(
|
|
4690
|
+
estimatedLimit,
|
|
4691
|
+
txMsg
|
|
4692
|
+
);
|
|
4693
|
+
} catch {
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
const compiled = solanaKit.compileTransaction(txMsg);
|
|
4697
|
+
const messageBase64 = Buffer.from(
|
|
4698
|
+
compiled.messageBytes
|
|
4699
|
+
).toString("base64");
|
|
4700
|
+
const signatureHex = await account.signTransaction({
|
|
4701
|
+
transaction: messageBase64
|
|
4702
|
+
});
|
|
4703
|
+
const sigBytes = new Uint8Array(
|
|
4704
|
+
Buffer.from(signatureHex.replace(/^0x/, ""), "hex")
|
|
4705
|
+
);
|
|
4706
|
+
const EMPTY_SIGNATURE = new Uint8Array(64);
|
|
4707
|
+
const signatures = Object.fromEntries(
|
|
4708
|
+
Object.entries(compiled.signatures).map(([addr]) => [
|
|
4709
|
+
addr,
|
|
4710
|
+
addr === userAddress ? sigBytes : EMPTY_SIGNATURE
|
|
4711
|
+
])
|
|
4712
|
+
);
|
|
4713
|
+
const signed = { ...compiled, signatures };
|
|
4714
|
+
const base64Full = solanaKit.getBase64EncodedWireTransaction(signed);
|
|
4715
|
+
const { signed_transaction } = await client.signTransaction({
|
|
4716
|
+
transaction: base64Full,
|
|
4717
|
+
signer_key: signer_address
|
|
4718
|
+
});
|
|
4719
|
+
const signature2 = await rpc.sendTransaction(
|
|
4720
|
+
signed_transaction,
|
|
4721
|
+
{ encoding: "base64" }
|
|
4722
|
+
).send();
|
|
4723
|
+
await confirmTransaction({
|
|
4724
|
+
commitment: "confirmed",
|
|
4725
|
+
signature: signature2,
|
|
4726
|
+
abortSignal: AbortSignal.timeout(6e4)
|
|
4727
|
+
});
|
|
4728
|
+
return { signature: signature2 };
|
|
4729
|
+
}
|
|
4730
|
+
|
|
4731
|
+
// src/wallets/solana/actions/sendRawTransaction.ts
|
|
4732
|
+
async function sendRawTransaction(options) {
|
|
4733
|
+
const {
|
|
4734
|
+
account,
|
|
4735
|
+
cluster,
|
|
4736
|
+
transaction,
|
|
4737
|
+
computeUnitLimit,
|
|
4738
|
+
computeUnitPrice,
|
|
4739
|
+
rpcUrl,
|
|
4740
|
+
wsUrl
|
|
4741
|
+
} = options;
|
|
4742
|
+
let solanaKit;
|
|
4743
|
+
try {
|
|
4744
|
+
solanaKit = await import("@solana/kit");
|
|
4745
|
+
} catch {
|
|
4746
|
+
throw new UserInputValidationError(
|
|
4747
|
+
"`@solana/kit` is required for sendRawTransaction. Install it and try again."
|
|
4748
|
+
);
|
|
4749
|
+
}
|
|
4750
|
+
const txBytes = new Uint8Array(Buffer.from(transaction, "base64"));
|
|
4751
|
+
const decoded = solanaKit.getTransactionDecoder().decode(txBytes);
|
|
4752
|
+
const compiledMessage = solanaKit.getCompiledTransactionMessageDecoder().decode(decoded.messageBytes);
|
|
4753
|
+
const rpc = solanaKit.createSolanaRpc(rpcUrl ?? getRpcEndpoint(cluster));
|
|
4754
|
+
const decompiled = await solanaKit.decompileTransactionMessageFetchingLookupTables(
|
|
4755
|
+
compiledMessage,
|
|
4756
|
+
rpc
|
|
4757
|
+
);
|
|
4758
|
+
return sendTransaction({
|
|
4759
|
+
account,
|
|
4760
|
+
cluster,
|
|
4761
|
+
instructions: [...decompiled.instructions],
|
|
4762
|
+
computeUnitLimit,
|
|
4763
|
+
computeUnitPrice,
|
|
4764
|
+
rpcUrl,
|
|
4765
|
+
wsUrl
|
|
4766
|
+
});
|
|
4767
|
+
}
|
|
4768
|
+
|
|
4655
4769
|
// src/wallets/solana/actions/signMessage.ts
|
|
4656
4770
|
async function signMessage(options) {
|
|
4657
4771
|
const { accountId, message } = options;
|
|
@@ -4674,6 +4788,150 @@ async function signTransaction(options) {
|
|
|
4674
4788
|
};
|
|
4675
4789
|
}
|
|
4676
4790
|
|
|
4791
|
+
// src/wallets/solana/actions/rpc.ts
|
|
4792
|
+
async function createRpcClient(cluster, rpcUrl) {
|
|
4793
|
+
let solanaKit;
|
|
4794
|
+
try {
|
|
4795
|
+
solanaKit = await import("@solana/kit");
|
|
4796
|
+
} catch {
|
|
4797
|
+
throw new UserInputValidationError(
|
|
4798
|
+
"`@solana/kit` is required. Install it and try again."
|
|
4799
|
+
);
|
|
4800
|
+
}
|
|
4801
|
+
return solanaKit.createSolanaRpc(rpcUrl ?? getRpcEndpoint(cluster));
|
|
4802
|
+
}
|
|
4803
|
+
|
|
4804
|
+
// src/wallets/solana/actions/transfer.ts
|
|
4805
|
+
async function transfer(options) {
|
|
4806
|
+
const { account, cluster, rpcUrl, ...rest } = options;
|
|
4807
|
+
const rpc = await createRpcClient(cluster, rpcUrl);
|
|
4808
|
+
const instructions = !options.token || options.token.toLowerCase() === "sol" ? await getNativeTransferInstructions({
|
|
4809
|
+
from: account.address,
|
|
4810
|
+
to: options.to,
|
|
4811
|
+
amount: options.amount
|
|
4812
|
+
}) : await getSplTransferInstructions({
|
|
4813
|
+
rpc,
|
|
4814
|
+
from: account.address,
|
|
4815
|
+
to: options.to,
|
|
4816
|
+
mintAddress: options.token.toLowerCase() === "usdc" ? getUsdcMintAddress(cluster) : options.token,
|
|
4817
|
+
amount: options.amount
|
|
4818
|
+
});
|
|
4819
|
+
return sendTransaction({
|
|
4820
|
+
account,
|
|
4821
|
+
cluster,
|
|
4822
|
+
instructions,
|
|
4823
|
+
rpcUrl,
|
|
4824
|
+
computeUnitLimit: rest.computeUnitLimit,
|
|
4825
|
+
computeUnitPrice: rest.computeUnitPrice,
|
|
4826
|
+
wsUrl: rest.wsUrl
|
|
4827
|
+
});
|
|
4828
|
+
}
|
|
4829
|
+
async function getNativeTransferInstructions({
|
|
4830
|
+
from,
|
|
4831
|
+
to,
|
|
4832
|
+
amount
|
|
4833
|
+
}) {
|
|
4834
|
+
let solanaKit;
|
|
4835
|
+
let systemProgram;
|
|
4836
|
+
try {
|
|
4837
|
+
solanaKit = await import("@solana/kit");
|
|
4838
|
+
} catch {
|
|
4839
|
+
throw new UserInputValidationError(
|
|
4840
|
+
"`@solana/kit` is required for transfer. Install it and try again."
|
|
4841
|
+
);
|
|
4842
|
+
}
|
|
4843
|
+
try {
|
|
4844
|
+
systemProgram = await import("@solana-program/system");
|
|
4845
|
+
} catch {
|
|
4846
|
+
throw new UserInputValidationError(
|
|
4847
|
+
"`@solana-program/system` is required for SOL transfers. Install it and try again."
|
|
4848
|
+
);
|
|
4849
|
+
}
|
|
4850
|
+
const fromAddr = solanaKit.address(from);
|
|
4851
|
+
const toAddr = solanaKit.address(to);
|
|
4852
|
+
return [
|
|
4853
|
+
systemProgram.getTransferSolInstruction({
|
|
4854
|
+
source: solanaKit.createNoopSigner(fromAddr),
|
|
4855
|
+
destination: toAddr,
|
|
4856
|
+
amount
|
|
4857
|
+
})
|
|
4858
|
+
];
|
|
4859
|
+
}
|
|
4860
|
+
async function getSplTransferInstructions({
|
|
4861
|
+
rpc,
|
|
4862
|
+
from,
|
|
4863
|
+
to,
|
|
4864
|
+
mintAddress,
|
|
4865
|
+
amount
|
|
4866
|
+
}) {
|
|
4867
|
+
let solanaKit;
|
|
4868
|
+
let tokenProgram;
|
|
4869
|
+
try {
|
|
4870
|
+
solanaKit = await import("@solana/kit");
|
|
4871
|
+
} catch {
|
|
4872
|
+
throw new UserInputValidationError(
|
|
4873
|
+
"`@solana/kit` is required for transfer. Install it and try again."
|
|
4874
|
+
);
|
|
4875
|
+
}
|
|
4876
|
+
try {
|
|
4877
|
+
tokenProgram = await import("@solana-program/token");
|
|
4878
|
+
} catch {
|
|
4879
|
+
throw new UserInputValidationError(
|
|
4880
|
+
"`@solana-program/token` is required for SPL transfers. Install it and try again."
|
|
4881
|
+
);
|
|
4882
|
+
}
|
|
4883
|
+
const fromAddr = solanaKit.address(from);
|
|
4884
|
+
const toAddr = solanaKit.address(to);
|
|
4885
|
+
const mintAddr = solanaKit.address(mintAddress);
|
|
4886
|
+
const mintInfo = await tokenProgram.fetchMint(rpc, mintAddr).catch(() => {
|
|
4887
|
+
throw new UserInputValidationError(
|
|
4888
|
+
`Failed to fetch mint account for ${mintAddress}. Verify the mint address is correct.`
|
|
4889
|
+
);
|
|
4890
|
+
});
|
|
4891
|
+
const [sourceAta] = await tokenProgram.findAssociatedTokenPda({
|
|
4892
|
+
mint: mintAddr,
|
|
4893
|
+
owner: fromAddr,
|
|
4894
|
+
tokenProgram: tokenProgram.TOKEN_PROGRAM_ADDRESS
|
|
4895
|
+
});
|
|
4896
|
+
const [destAta] = await tokenProgram.findAssociatedTokenPda({
|
|
4897
|
+
mint: mintAddr,
|
|
4898
|
+
owner: toAddr,
|
|
4899
|
+
tokenProgram: tokenProgram.TOKEN_PROGRAM_ADDRESS
|
|
4900
|
+
});
|
|
4901
|
+
const sourceAcct = await tokenProgram.fetchToken(rpc, sourceAta).catch(() => {
|
|
4902
|
+
throw new UserInputValidationError(
|
|
4903
|
+
`Source account has no token account for mint ${mintAddress}`
|
|
4904
|
+
);
|
|
4905
|
+
});
|
|
4906
|
+
if (sourceAcct.data.amount < amount) {
|
|
4907
|
+
throw new UserInputValidationError(
|
|
4908
|
+
`Insufficient token balance: have ${sourceAcct.data.amount}, need ${amount}`
|
|
4909
|
+
);
|
|
4910
|
+
}
|
|
4911
|
+
const instructions = [];
|
|
4912
|
+
const destAccountInfo = await rpc.getAccountInfo(destAta, { encoding: "base64" }).send();
|
|
4913
|
+
if (!destAccountInfo.value) {
|
|
4914
|
+
const createDestIx = await tokenProgram.getCreateAssociatedTokenInstructionAsync({
|
|
4915
|
+
payer: solanaKit.createNoopSigner(fromAddr),
|
|
4916
|
+
owner: toAddr,
|
|
4917
|
+
ata: destAta,
|
|
4918
|
+
mint: mintAddr
|
|
4919
|
+
});
|
|
4920
|
+
instructions.push(createDestIx);
|
|
4921
|
+
}
|
|
4922
|
+
instructions.push(
|
|
4923
|
+
tokenProgram.getTransferCheckedInstruction({
|
|
4924
|
+
source: sourceAta,
|
|
4925
|
+
mint: mintAddr,
|
|
4926
|
+
destination: destAta,
|
|
4927
|
+
authority: solanaKit.createNoopSigner(fromAddr),
|
|
4928
|
+
amount,
|
|
4929
|
+
decimals: mintInfo.data.decimals
|
|
4930
|
+
})
|
|
4931
|
+
);
|
|
4932
|
+
return instructions;
|
|
4933
|
+
}
|
|
4934
|
+
|
|
4677
4935
|
// src/wallets/solana/accounts/solanaAccount.ts
|
|
4678
4936
|
function toSolanaAccount(data) {
|
|
4679
4937
|
const { id, address } = data;
|
|
@@ -4694,6 +4952,12 @@ function toSolanaAccount(data) {
|
|
|
4694
4952
|
transaction: parameters.transaction
|
|
4695
4953
|
});
|
|
4696
4954
|
return result.signedTransaction;
|
|
4955
|
+
},
|
|
4956
|
+
async transfer(options) {
|
|
4957
|
+
return transfer({ ...options, account });
|
|
4958
|
+
},
|
|
4959
|
+
async sendRawTransaction(options) {
|
|
4960
|
+
return sendRawTransaction({ ...options, account });
|
|
4697
4961
|
}
|
|
4698
4962
|
};
|
|
4699
4963
|
return account;
|
|
@@ -4771,13 +5035,14 @@ var SolanaClient = class {
|
|
|
4771
5035
|
);
|
|
4772
5036
|
}
|
|
4773
5037
|
if (options.id) {
|
|
4774
|
-
const response = await
|
|
5038
|
+
const response = await getAccountV2(options.id);
|
|
4775
5039
|
return toSolanaAccount(toSolanaAccountData(response));
|
|
4776
5040
|
}
|
|
4777
5041
|
if (options.address) {
|
|
4778
|
-
const wallets = await
|
|
5042
|
+
const wallets = await getAccountsV2({
|
|
4779
5043
|
address: options.address,
|
|
4780
5044
|
chainType: "SVM",
|
|
5045
|
+
custody: "Developer",
|
|
4781
5046
|
limit: 1
|
|
4782
5047
|
});
|
|
4783
5048
|
if (wallets.data.length === 0) {
|
|
@@ -4801,10 +5066,11 @@ var SolanaClient = class {
|
|
|
4801
5066
|
* ```
|
|
4802
5067
|
*/
|
|
4803
5068
|
async listAccounts(options = {}) {
|
|
4804
|
-
const response = await
|
|
5069
|
+
const response = await getAccountsV2({
|
|
4805
5070
|
limit: options.limit,
|
|
4806
5071
|
skip: options.skip,
|
|
4807
|
-
chainType: "SVM"
|
|
5072
|
+
chainType: "SVM",
|
|
5073
|
+
custody: "Developer"
|
|
4808
5074
|
});
|
|
4809
5075
|
const accounts = response.data.map(
|
|
4810
5076
|
(wallet) => toSolanaAccount(toSolanaAccountData(wallet))
|
|
@@ -4922,11 +5188,110 @@ var SolanaClient = class {
|
|
|
4922
5188
|
return response.signature;
|
|
4923
5189
|
}
|
|
4924
5190
|
};
|
|
5191
|
+
/** Wallet type identifier used for client registration */
|
|
4925
5192
|
SolanaClient.type = "solanaWallet";
|
|
4926
5193
|
|
|
4927
5194
|
// src/index.ts
|
|
4928
5195
|
var import_shield_js2 = require("@openfort/shield-js");
|
|
4929
5196
|
|
|
5197
|
+
// src/wallets/evm/actions/updateToDelegated.ts
|
|
5198
|
+
async function update(options) {
|
|
5199
|
+
const { chainId, walletId, implementationType, accountId } = options;
|
|
5200
|
+
return createAccountV2({
|
|
5201
|
+
accountType: "Delegated Account",
|
|
5202
|
+
chainType: "EVM",
|
|
5203
|
+
chainId,
|
|
5204
|
+
user: walletId,
|
|
5205
|
+
implementationType,
|
|
5206
|
+
account: accountId
|
|
5207
|
+
});
|
|
5208
|
+
}
|
|
5209
|
+
|
|
5210
|
+
// src/wallets/evm/actions/sendTransaction.ts
|
|
5211
|
+
async function sendTransaction2(options) {
|
|
5212
|
+
let viem;
|
|
5213
|
+
let viemChains;
|
|
5214
|
+
let viemUtils;
|
|
5215
|
+
try {
|
|
5216
|
+
viem = await import("viem");
|
|
5217
|
+
} catch {
|
|
5218
|
+
throw new UserInputValidationError(
|
|
5219
|
+
"`viem` is required for sendTransaction. Install it and try again."
|
|
5220
|
+
);
|
|
5221
|
+
}
|
|
5222
|
+
try {
|
|
5223
|
+
viemChains = await import("viem/chains");
|
|
5224
|
+
} catch {
|
|
5225
|
+
throw new UserInputValidationError(
|
|
5226
|
+
"`viem` is required for sendTransaction. Install it and try again."
|
|
5227
|
+
);
|
|
5228
|
+
}
|
|
5229
|
+
try {
|
|
5230
|
+
viemUtils = await import("viem/utils");
|
|
5231
|
+
} catch {
|
|
5232
|
+
throw new UserInputValidationError(
|
|
5233
|
+
"`viem` is required for sendTransaction. Install it and try again."
|
|
5234
|
+
);
|
|
5235
|
+
}
|
|
5236
|
+
const { account, chainId, interactions, policy, rpcUrl } = options;
|
|
5237
|
+
const transport = rpcUrl ? viem.http(rpcUrl) : viem.http();
|
|
5238
|
+
const allChains = Object.values(viemChains);
|
|
5239
|
+
const chain = allChains.find(
|
|
5240
|
+
(c) => typeof c === "object" && c !== null && "id" in c && c.id === chainId
|
|
5241
|
+
);
|
|
5242
|
+
if (!chain) {
|
|
5243
|
+
throw new DelegationError(
|
|
5244
|
+
`Unknown chain ID ${chainId}. Provide a custom rpcUrl for unsupported chains.`
|
|
5245
|
+
);
|
|
5246
|
+
}
|
|
5247
|
+
let signedAuthorization;
|
|
5248
|
+
let txAccountId;
|
|
5249
|
+
const response = await getAccountsV2({
|
|
5250
|
+
address: viem.getAddress(account.address),
|
|
5251
|
+
accountType: "Delegated Account",
|
|
5252
|
+
chainType: "EVM",
|
|
5253
|
+
chainId
|
|
5254
|
+
});
|
|
5255
|
+
if (response.data.length === 0) {
|
|
5256
|
+
const updated = await update({
|
|
5257
|
+
walletId: account.walletId,
|
|
5258
|
+
chainId,
|
|
5259
|
+
implementationType: "Calibur",
|
|
5260
|
+
accountId: account.id
|
|
5261
|
+
});
|
|
5262
|
+
txAccountId = updated.id;
|
|
5263
|
+
const implementationAddress = "0x000000009b1d0af20d8c6d0a44e162d11f9b8f00";
|
|
5264
|
+
const publicClient = viem.createPublicClient({ chain, transport });
|
|
5265
|
+
const eoaNonce = await publicClient.getTransactionCount({
|
|
5266
|
+
address: account.address
|
|
5267
|
+
});
|
|
5268
|
+
const authHash = viemUtils.hashAuthorization({
|
|
5269
|
+
contractAddress: implementationAddress,
|
|
5270
|
+
chainId,
|
|
5271
|
+
nonce: eoaNonce
|
|
5272
|
+
});
|
|
5273
|
+
signedAuthorization = await account.sign({ hash: authHash });
|
|
5274
|
+
} else {
|
|
5275
|
+
txAccountId = response.data[0].id;
|
|
5276
|
+
}
|
|
5277
|
+
const txIntent = await createTransactionIntent({
|
|
5278
|
+
chainId,
|
|
5279
|
+
account: txAccountId,
|
|
5280
|
+
policy,
|
|
5281
|
+
signedAuthorization,
|
|
5282
|
+
interactions
|
|
5283
|
+
});
|
|
5284
|
+
if (!txIntent.nextAction?.payload?.signableHash) {
|
|
5285
|
+
return txIntent;
|
|
5286
|
+
}
|
|
5287
|
+
const txSignature = await account.sign({
|
|
5288
|
+
hash: txIntent.nextAction.payload.signableHash
|
|
5289
|
+
});
|
|
5290
|
+
return signature(txIntent.id, {
|
|
5291
|
+
signature: txSignature
|
|
5292
|
+
});
|
|
5293
|
+
}
|
|
5294
|
+
|
|
4930
5295
|
// src/policies/evmSchema.ts
|
|
4931
5296
|
var import_zod = require("zod");
|
|
4932
5297
|
var EthValueOperatorEnum = import_zod.z.enum(["<=", ">=", "<", ">"]);
|
|
@@ -5232,15 +5597,6 @@ var UpdatePolicyBodySchema = import_zod3.z.object({
|
|
|
5232
5597
|
rules: import_zod3.z.array(RuleSchema).min(1).max(10).optional()
|
|
5233
5598
|
});
|
|
5234
5599
|
|
|
5235
|
-
// src/wallets/evm/actions/signMessage.ts
|
|
5236
|
-
var import_viem2 = require("viem");
|
|
5237
|
-
|
|
5238
|
-
// src/wallets/evm/actions/signTransaction.ts
|
|
5239
|
-
var import_viem3 = require("viem");
|
|
5240
|
-
|
|
5241
|
-
// src/wallets/evm/actions/signTypedData.ts
|
|
5242
|
-
var import_viem4 = require("viem");
|
|
5243
|
-
|
|
5244
5600
|
// src/index.ts
|
|
5245
5601
|
function isValidSecretKey(key) {
|
|
5246
5602
|
return key.startsWith("sk_test_") || key.startsWith("sk_live_");
|
|
@@ -5336,7 +5692,9 @@ var Openfort = class {
|
|
|
5336
5692
|
/** Export private key (with E2E encryption) */
|
|
5337
5693
|
export: evmClient.exportAccount.bind(evmClient),
|
|
5338
5694
|
/** Update EOA to delegated account */
|
|
5339
|
-
update
|
|
5695
|
+
update,
|
|
5696
|
+
/** Delegate + create + sign + submit a gasless transaction in one call */
|
|
5697
|
+
sendTransaction: sendTransaction2
|
|
5340
5698
|
},
|
|
5341
5699
|
/** Embedded wallet operations (User custody) */
|
|
5342
5700
|
embedded: {
|
|
@@ -5365,7 +5723,13 @@ var Openfort = class {
|
|
|
5365
5723
|
/** Import private key (with E2E encryption) */
|
|
5366
5724
|
import: solanaClient.importAccount.bind(solanaClient),
|
|
5367
5725
|
/** Export private key (with E2E encryption) */
|
|
5368
|
-
export: solanaClient.exportAccount.bind(solanaClient)
|
|
5726
|
+
export: solanaClient.exportAccount.bind(solanaClient),
|
|
5727
|
+
/** Send a gasless transaction via Kora */
|
|
5728
|
+
sendTransaction,
|
|
5729
|
+
/** Send a pre-built base64 transaction via Kora gasless flow */
|
|
5730
|
+
sendRawTransaction,
|
|
5731
|
+
/** Transfer SOL or SPL tokens (high-level) */
|
|
5732
|
+
transfer
|
|
5369
5733
|
},
|
|
5370
5734
|
/** Embedded wallet operations (User custody) */
|
|
5371
5735
|
embedded: {
|
|
@@ -5556,10 +5920,14 @@ var Openfort = class {
|
|
|
5556
5920
|
* gas costs are sponsored according to the policy's strategy.
|
|
5557
5921
|
*/
|
|
5558
5922
|
get transactionIntents() {
|
|
5923
|
+
if (!this._evmClient) {
|
|
5924
|
+
this._evmClient = new EvmClient();
|
|
5925
|
+
}
|
|
5926
|
+
const _evmClient = this._evmClient;
|
|
5559
5927
|
return {
|
|
5560
5928
|
/** List transaction intents */
|
|
5561
5929
|
list: getTransactionIntents,
|
|
5562
|
-
/** Create a transaction intent with contract interactions */
|
|
5930
|
+
/** Create a transaction intent with contract interactions. */
|
|
5563
5931
|
create: createTransactionIntent,
|
|
5564
5932
|
/** Get a transaction intent by ID */
|
|
5565
5933
|
get: getTransactionIntent,
|
|
@@ -5704,9 +6072,7 @@ var Openfort = class {
|
|
|
5704
6072
|
/** Verify auth token */
|
|
5705
6073
|
verifyToken: verifyAuthToken,
|
|
5706
6074
|
/** Verify OAuth token */
|
|
5707
|
-
verifyOAuthToken
|
|
5708
|
-
/** Authorize */
|
|
5709
|
-
authorize
|
|
6075
|
+
verifyOAuthToken
|
|
5710
6076
|
}
|
|
5711
6077
|
};
|
|
5712
6078
|
}
|
|
@@ -5915,11 +6281,6 @@ var index_default = Openfort;
|
|
|
5915
6281
|
AuthProviderResponseV2,
|
|
5916
6282
|
AuthenticateOAuthRequestProvider,
|
|
5917
6283
|
AuthenticationType,
|
|
5918
|
-
BackendWalletListQueriesChainType,
|
|
5919
|
-
BackendWalletListResponseObject,
|
|
5920
|
-
BackendWalletResponseChainType,
|
|
5921
|
-
BackendWalletResponseCustody,
|
|
5922
|
-
BackendWalletResponseObject,
|
|
5923
6284
|
BasicAuthProvider,
|
|
5924
6285
|
BasicAuthProviderEMAIL,
|
|
5925
6286
|
BasicAuthProviderGUEST,
|
|
@@ -5947,6 +6308,7 @@ var index_default = Openfort;
|
|
|
5947
6308
|
CriteriaOperatorNOTIN,
|
|
5948
6309
|
CriteriaType,
|
|
5949
6310
|
Currency,
|
|
6311
|
+
DelegationError,
|
|
5950
6312
|
DeleteBackendWalletResponseObject,
|
|
5951
6313
|
DeveloperAccountResponseExpandable,
|
|
5952
6314
|
EmailTypeRequest,
|
|
@@ -6031,7 +6393,6 @@ var index_default = Openfort;
|
|
|
6031
6393
|
JsonRpcErrorResponseJsonrpc,
|
|
6032
6394
|
JsonRpcRequestJsonrpc,
|
|
6033
6395
|
JsonRpcSuccessResponseAnyJsonrpc,
|
|
6034
|
-
ListBackendWalletsChainType,
|
|
6035
6396
|
ListPoliciesScopeItem,
|
|
6036
6397
|
MintAddressCriterionOperator,
|
|
6037
6398
|
MintAddressCriterionRequestOperator,
|
|
@@ -6161,12 +6522,6 @@ var index_default = Openfort;
|
|
|
6161
6522
|
TransactionIntentResponseExpandable,
|
|
6162
6523
|
TransactionStatus,
|
|
6163
6524
|
UnknownError,
|
|
6164
|
-
UpdateBackendWalletRequestAccountType,
|
|
6165
|
-
UpdateBackendWalletRequestChainType,
|
|
6166
|
-
UpdateBackendWalletResponseChainType,
|
|
6167
|
-
UpdateBackendWalletResponseCustody,
|
|
6168
|
-
UpdateBackendWalletResponseDelegatedAccountChainChainType,
|
|
6169
|
-
UpdateBackendWalletResponseObject,
|
|
6170
6525
|
UpdatePolicyBodySchema,
|
|
6171
6526
|
UsageAlertType,
|
|
6172
6527
|
UserInputValidationError,
|
|
@@ -6179,7 +6534,6 @@ var index_default = Openfort;
|
|
|
6179
6534
|
authApi,
|
|
6180
6535
|
authSchemas,
|
|
6181
6536
|
authenticateSIWE,
|
|
6182
|
-
authorize,
|
|
6183
6537
|
callbackOAuth,
|
|
6184
6538
|
cancelTransferAccountOwnership,
|
|
6185
6539
|
configure,
|
|
@@ -6241,7 +6595,6 @@ var index_default = Openfort;
|
|
|
6241
6595
|
getAuthPlayers,
|
|
6242
6596
|
getAuthUser,
|
|
6243
6597
|
getAuthUsers,
|
|
6244
|
-
getBackendWallet,
|
|
6245
6598
|
getConfig,
|
|
6246
6599
|
getContract,
|
|
6247
6600
|
getContracts,
|
|
@@ -6290,7 +6643,6 @@ var index_default = Openfort;
|
|
|
6290
6643
|
linkSIWE,
|
|
6291
6644
|
linkThirdParty,
|
|
6292
6645
|
list,
|
|
6293
|
-
listBackendWallets,
|
|
6294
6646
|
listFeeSponsorships,
|
|
6295
6647
|
listForwarderContracts,
|
|
6296
6648
|
listOAuthConfig,
|
|
@@ -6298,7 +6650,6 @@ var index_default = Openfort;
|
|
|
6298
6650
|
listPolicies,
|
|
6299
6651
|
listSubscriptionLogs,
|
|
6300
6652
|
loginEmailPassword,
|
|
6301
|
-
loginOIDC,
|
|
6302
6653
|
loginWithIdToken,
|
|
6303
6654
|
logout,
|
|
6304
6655
|
me,
|
|
@@ -6332,7 +6683,6 @@ var index_default = Openfort;
|
|
|
6332
6683
|
unlinkEmail,
|
|
6333
6684
|
unlinkOAuth,
|
|
6334
6685
|
unlinkSIWE,
|
|
6335
|
-
updateBackendWallet,
|
|
6336
6686
|
updateContract,
|
|
6337
6687
|
updateDeveloperAccount,
|
|
6338
6688
|
updateFeeSponsorship,
|