@startale/app-sdk 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/app-sdk.js +74 -40
- package/dist/app-sdk.js.map +1 -1
- package/dist/app-sdk.min.js +5 -5
- package/dist/app-sdk.min.js.map +1 -1
- package/dist/browser-entry.d.ts +1 -1
- package/dist/browser-entry.d.ts.map +1 -1
- package/dist/browser-entry.js +3 -3
- package/dist/browser-entry.js.map +1 -1
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/constants.js.map +1 -1
- package/dist/core/provider/interface.d.ts +16 -1
- package/dist/core/provider/interface.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/interface/builder/core/{createBaseAccountSDK.d.ts → createStartaleAccountSDK.d.ts} +6 -6
- package/dist/interface/builder/core/createStartaleAccountSDK.d.ts.map +1 -0
- package/dist/interface/builder/core/{createBaseAccountSDK.js → createStartaleAccountSDK.js} +5 -5
- package/dist/interface/builder/core/createStartaleAccountSDK.js.map +1 -0
- package/dist/interface/payment/utils/sdkManager.d.ts +2 -2
- package/dist/interface/payment/utils/sdkManager.d.ts.map +1 -1
- package/dist/interface/payment/utils/sdkManager.js +2 -2
- package/dist/interface/payment/utils/sdkManager.js.map +1 -1
- package/dist/kms/crypto-key/index.js +1 -1
- package/dist/kms/crypto-key/index.js.map +1 -1
- package/dist/sign/app-sdk/Signer.d.ts.map +1 -1
- package/dist/sign/app-sdk/Signer.js +4 -3
- package/dist/sign/app-sdk/Signer.js.map +1 -1
- package/dist/sign/app-sdk/utils.d.ts +6 -0
- package/dist/sign/app-sdk/utils.d.ts.map +1 -1
- package/dist/sign/app-sdk/utils.js +24 -3
- package/dist/sign/app-sdk/utils.js.map +1 -1
- package/dist/startale-connector.d.ts +41 -0
- package/dist/startale-connector.d.ts.map +1 -0
- package/dist/startale-connector.js +245 -0
- package/dist/startale-connector.js.map +1 -0
- package/dist/store/store.d.ts +2 -2
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +1 -1
- package/dist/store/store.js.map +1 -1
- package/package.json +3 -2
- package/dist/interface/builder/core/createBaseAccountSDK.d.ts.map +0 -1
- package/dist/interface/builder/core/createBaseAccountSDK.js.map +0 -1
package/README.md
CHANGED
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
1. Initialize Startale App SDK
|
|
64
64
|
|
|
65
65
|
```js
|
|
66
|
-
const sdk =
|
|
66
|
+
const sdk = createStartaleAccountSDK({
|
|
67
67
|
appName: 'SDK Playground',
|
|
68
68
|
});
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
2. Make
|
|
71
|
+
2. Make Startale App Provider
|
|
72
72
|
|
|
73
73
|
```js
|
|
74
74
|
const provider = sdk.getProvider();
|
package/dist/app-sdk.js
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var name = "@startale/app-sdk";
|
|
8
|
-
var version$4 = "1.
|
|
8
|
+
var version$4 = "1.1.0";
|
|
9
9
|
var pkg = {
|
|
10
10
|
name: name,
|
|
11
11
|
version: version$4};
|
|
12
12
|
|
|
13
|
-
const CB_KEYS_URL = 'https://
|
|
13
|
+
const CB_KEYS_URL = 'https://app.startale.com';
|
|
14
14
|
const CB_WALLET_RPC_URL = 'https://rpc.wallet.coinbase.com';
|
|
15
15
|
const PACKAGE_NAME = pkg.name;
|
|
16
16
|
const PACKAGE_VERSION = pkg.version;
|
|
@@ -271,7 +271,7 @@
|
|
|
271
271
|
};
|
|
272
272
|
};
|
|
273
273
|
const sdkstore = createStore$1(persist((...args) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, createChainSlice(...args)), createKeysSlice(...args)), createAccountSlice(...args)), createSubAccountSlice(...args)), createSpendPermissionsSlice(...args)), createConfigSlice(...args)), createSubAccountConfigSlice(...args)), createUserInfoSlice(...args))), {
|
|
274
|
-
name: '
|
|
274
|
+
name: 'startale-app-sdk.store',
|
|
275
275
|
storage: createJSONStorage(() => localStorage),
|
|
276
276
|
partialize: (state) => {
|
|
277
277
|
// Explicitly select only the data properties we want to persist
|
|
@@ -7675,7 +7675,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
7675
7675
|
return value.length;
|
|
7676
7676
|
}
|
|
7677
7677
|
|
|
7678
|
-
const version$2 = '2.38.
|
|
7678
|
+
const version$2 = '2.38.4';
|
|
7679
7679
|
|
|
7680
7680
|
let errorConfig = {
|
|
7681
7681
|
getDocsUrl: ({ docsBaseUrl, docsPath = '', docsSlug, }) => docsPath
|
|
@@ -12027,6 +12027,8 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
12027
12027
|
}
|
|
12028
12028
|
if (typeof request.data !== 'undefined')
|
|
12029
12029
|
rpcRequest.data = request.data;
|
|
12030
|
+
if (request.account)
|
|
12031
|
+
rpcRequest.from = request.account.address;
|
|
12030
12032
|
if (typeof request.from !== 'undefined')
|
|
12031
12033
|
rpcRequest.from = request.from;
|
|
12032
12034
|
if (typeof request.gas !== 'undefined')
|
|
@@ -13491,9 +13493,8 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
13491
13493
|
if (parameters.includes('gas') && typeof gas === 'undefined')
|
|
13492
13494
|
request.gas = await getAction(client, estimateGas, 'estimateGas')({
|
|
13493
13495
|
...request,
|
|
13494
|
-
account
|
|
13495
|
-
|
|
13496
|
-
: account,
|
|
13496
|
+
account,
|
|
13497
|
+
prepare: account?.type === 'local' ? [] : ['blobVersionedHashes'],
|
|
13497
13498
|
});
|
|
13498
13499
|
assertRequest(request);
|
|
13499
13500
|
delete request.parameters;
|
|
@@ -13526,16 +13527,24 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
13526
13527
|
* })
|
|
13527
13528
|
*/
|
|
13528
13529
|
async function estimateGas(client, args) {
|
|
13529
|
-
const { account: account_ = client.account } = args;
|
|
13530
|
+
const { account: account_ = client.account, prepare = true } = args;
|
|
13530
13531
|
const account = account_ ? parseAccount(account_) : undefined;
|
|
13532
|
+
const parameters = (() => {
|
|
13533
|
+
if (Array.isArray(prepare))
|
|
13534
|
+
return prepare;
|
|
13535
|
+
// Some RPC Providers do not compute versioned hashes from blobs. We will need
|
|
13536
|
+
// to compute them.
|
|
13537
|
+
if (account?.type !== 'local')
|
|
13538
|
+
return ['blobVersionedHashes'];
|
|
13539
|
+
return undefined;
|
|
13540
|
+
})();
|
|
13531
13541
|
try {
|
|
13532
|
-
const { accessList, authorizationList, blobs, blobVersionedHashes, blockNumber, blockTag, data, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, value, stateOverride, ...rest } =
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
}));
|
|
13542
|
+
const { accessList, authorizationList, blobs, blobVersionedHashes, blockNumber, blockTag, data, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, value, stateOverride, ...rest } = prepare
|
|
13543
|
+
? (await prepareTransactionRequest(client, {
|
|
13544
|
+
...args,
|
|
13545
|
+
parameters,
|
|
13546
|
+
}))
|
|
13547
|
+
: args;
|
|
13539
13548
|
const blockNumberHex = typeof blockNumber === 'bigint' ? numberToHex(blockNumber) : undefined;
|
|
13540
13549
|
const block = blockNumberHex || blockTag;
|
|
13541
13550
|
const rpcStateOverride = serializeStateOverride(stateOverride);
|
|
@@ -13560,7 +13569,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
13560
13569
|
const request = format({
|
|
13561
13570
|
// Pick out extra data that might exist on the chain's transaction request type.
|
|
13562
13571
|
...extract$1(rest, { format: chainFormat }),
|
|
13563
|
-
|
|
13572
|
+
account,
|
|
13564
13573
|
accessList,
|
|
13565
13574
|
authorizationList,
|
|
13566
13575
|
blobs,
|
|
@@ -14354,16 +14363,17 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
14354
14363
|
return options.cause.docsPath || options.docsPath;
|
|
14355
14364
|
return options.docsPath;
|
|
14356
14365
|
})();
|
|
14357
|
-
const docsBaseUrl = 'https://oxlib.sh';
|
|
14366
|
+
const docsBaseUrl = options.docsOrigin ?? 'https://oxlib.sh';
|
|
14358
14367
|
const docs = `${docsBaseUrl}${docsPath ?? ''}`;
|
|
14359
14368
|
const message = [
|
|
14360
14369
|
shortMessage || 'An error occurred.',
|
|
14361
14370
|
...(options.metaMessages ? ['', ...options.metaMessages] : []),
|
|
14362
|
-
...(details || docsPath
|
|
14371
|
+
...(details || docsPath || options.version
|
|
14363
14372
|
? [
|
|
14364
14373
|
'',
|
|
14365
14374
|
details ? `Details: ${details}` : undefined,
|
|
14366
14375
|
docsPath ? `See: ${docs}` : undefined,
|
|
14376
|
+
options.version ? `Version: ${options.version}` : undefined,
|
|
14367
14377
|
]
|
|
14368
14378
|
: []),
|
|
14369
14379
|
]
|
|
@@ -14394,29 +14404,30 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
14394
14404
|
writable: true,
|
|
14395
14405
|
value: void 0
|
|
14396
14406
|
});
|
|
14397
|
-
Object.defineProperty(this, "
|
|
14407
|
+
Object.defineProperty(this, "version", {
|
|
14398
14408
|
enumerable: true,
|
|
14399
14409
|
configurable: true,
|
|
14400
14410
|
writable: true,
|
|
14401
14411
|
value: void 0
|
|
14402
14412
|
});
|
|
14403
|
-
Object.defineProperty(this, "
|
|
14413
|
+
Object.defineProperty(this, "cause", {
|
|
14404
14414
|
enumerable: true,
|
|
14405
14415
|
configurable: true,
|
|
14406
14416
|
writable: true,
|
|
14407
|
-
value:
|
|
14417
|
+
value: void 0
|
|
14408
14418
|
});
|
|
14409
|
-
Object.defineProperty(this, "
|
|
14419
|
+
Object.defineProperty(this, "name", {
|
|
14410
14420
|
enumerable: true,
|
|
14411
14421
|
configurable: true,
|
|
14412
14422
|
writable: true,
|
|
14413
|
-
value:
|
|
14423
|
+
value: 'BaseError'
|
|
14414
14424
|
});
|
|
14415
14425
|
this.cause = options.cause;
|
|
14416
14426
|
this.details = details;
|
|
14417
14427
|
this.docs = docs;
|
|
14418
14428
|
this.docsPath = docsPath;
|
|
14419
14429
|
this.shortMessage = shortMessage;
|
|
14430
|
+
this.version = options.version ?? `ox@${getVersion()}`;
|
|
14420
14431
|
}
|
|
14421
14432
|
walk(fn) {
|
|
14422
14433
|
return walk(this, fn);
|
|
@@ -14712,7 +14723,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
14712
14723
|
if (nibbleLeft === undefined || nibbleRight === undefined) {
|
|
14713
14724
|
throw new BaseError$1(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
|
|
14714
14725
|
}
|
|
14715
|
-
bytes[index] = nibbleLeft
|
|
14726
|
+
bytes[index] = (nibbleLeft << 4) | nibbleRight;
|
|
14716
14727
|
}
|
|
14717
14728
|
return bytes;
|
|
14718
14729
|
}
|
|
@@ -15264,7 +15275,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
15264
15275
|
value: `${value}${suffix}`,
|
|
15265
15276
|
});
|
|
15266
15277
|
}
|
|
15267
|
-
const stringValue = (signed && value_ < 0 ?
|
|
15278
|
+
const stringValue = (signed && value_ < 0 ? BigInt.asUintN(size * 8, BigInt(value_)) : value_).toString(16);
|
|
15268
15279
|
const hex = `0x${stringValue}`;
|
|
15269
15280
|
if (size)
|
|
15270
15281
|
return padLeft(hex, size);
|
|
@@ -16244,8 +16255,8 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
16244
16255
|
const request = format({
|
|
16245
16256
|
// Pick out extra data that might exist on the chain's transaction request type.
|
|
16246
16257
|
...extract$1(rest, { format: chainFormat }),
|
|
16247
|
-
from: account?.address,
|
|
16248
16258
|
accessList,
|
|
16259
|
+
account,
|
|
16249
16260
|
authorizationList,
|
|
16250
16261
|
blobs,
|
|
16251
16262
|
data,
|
|
@@ -18318,7 +18329,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
18318
18329
|
const request = format({
|
|
18319
18330
|
// Pick out extra data that might exist on the chain's transaction request type.
|
|
18320
18331
|
...extract$1(rest, { format: chainFormat }),
|
|
18321
|
-
|
|
18332
|
+
account,
|
|
18322
18333
|
blobs,
|
|
18323
18334
|
data,
|
|
18324
18335
|
gas,
|
|
@@ -25735,6 +25746,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
25735
25746
|
const data = call.abi ? encodeFunctionData(call) : call.data;
|
|
25736
25747
|
const request = {
|
|
25737
25748
|
...call,
|
|
25749
|
+
account,
|
|
25738
25750
|
data: call.dataSuffix
|
|
25739
25751
|
? concat$1([data || '0x', call.dataSuffix])
|
|
25740
25752
|
: data,
|
|
@@ -33378,7 +33390,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
33378
33390
|
const sign = async (payload) => {
|
|
33379
33391
|
const { payload: message, metadata } = getSignPayload({
|
|
33380
33392
|
challenge: payload,
|
|
33381
|
-
origin: 'https://
|
|
33393
|
+
origin: 'https://app.startale.com',
|
|
33382
33394
|
userVerification: 'preferred',
|
|
33383
33395
|
});
|
|
33384
33396
|
const signature = await sign$1({
|
|
@@ -33697,7 +33709,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
33697
33709
|
throw standardErrors.rpc.internal('failed to send transaction');
|
|
33698
33710
|
}
|
|
33699
33711
|
function createWalletSendCallsRequest({ calls, from, chainId, capabilities, }) {
|
|
33700
|
-
const
|
|
33712
|
+
const paymasterOptions = config.get().paymasterOptions;
|
|
33701
33713
|
let request = {
|
|
33702
33714
|
method: 'wallet_sendCalls',
|
|
33703
33715
|
params: [
|
|
@@ -33711,9 +33723,9 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
33711
33723
|
},
|
|
33712
33724
|
],
|
|
33713
33725
|
};
|
|
33714
|
-
if (
|
|
33726
|
+
if (paymasterOptions === null || paymasterOptions === void 0 ? void 0 : paymasterOptions[chainId]) {
|
|
33715
33727
|
request = injectRequestCapabilities(request, {
|
|
33716
|
-
paymasterService: { url:
|
|
33728
|
+
paymasterService: { url: paymasterOptions === null || paymasterOptions === void 0 ? void 0 : paymasterOptions[chainId].url, id: paymasterOptions === null || paymasterOptions === void 0 ? void 0 : paymasterOptions[chainId].id },
|
|
33717
33729
|
});
|
|
33718
33730
|
}
|
|
33719
33731
|
return request;
|
|
@@ -33848,6 +33860,27 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
33848
33860
|
accounts: walletConnectAccounts,
|
|
33849
33861
|
};
|
|
33850
33862
|
}
|
|
33863
|
+
/** Adds paymaster service information to a wallet_sendCalls request if configured for the given chainId
|
|
33864
|
+
* @param request The original request object
|
|
33865
|
+
* @param chainId The chain ID to check for paymaster configuration
|
|
33866
|
+
* @returns The modified request object with paymaster information if applicable
|
|
33867
|
+
*/
|
|
33868
|
+
function addPaymasterToRequest(request, chainId) {
|
|
33869
|
+
if (request.method !== 'wallet_sendCalls') {
|
|
33870
|
+
return request;
|
|
33871
|
+
}
|
|
33872
|
+
const paymasterOptions = config.get().paymasterOptions;
|
|
33873
|
+
const optionsForChain = paymasterOptions === null || paymasterOptions === void 0 ? void 0 : paymasterOptions[chainId];
|
|
33874
|
+
if (!optionsForChain) {
|
|
33875
|
+
return request;
|
|
33876
|
+
}
|
|
33877
|
+
return injectRequestCapabilities(request, {
|
|
33878
|
+
paymasterService: {
|
|
33879
|
+
url: optionsForChain.url,
|
|
33880
|
+
id: optionsForChain.id,
|
|
33881
|
+
},
|
|
33882
|
+
});
|
|
33883
|
+
}
|
|
33851
33884
|
|
|
33852
33885
|
function base64ToBase64Url(base64) {
|
|
33853
33886
|
return base64.replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
|
|
@@ -34882,9 +34915,10 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
34882
34915
|
// Open the popup before constructing the request message.
|
|
34883
34916
|
// This is to ensure that the popup is not blocked by some browsers (i.e. Safari)
|
|
34884
34917
|
await ((_b = (_a = this.communicator).waitForPopupLoaded) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
34885
|
-
const
|
|
34918
|
+
const requestWithPaymaster = addPaymasterToRequest(request, this.chain.id);
|
|
34919
|
+
const response = await this.sendEncryptedRequest(requestWithPaymaster);
|
|
34886
34920
|
const decrypted = await this.decryptResponseMessage(response);
|
|
34887
|
-
return this.handleResponse(
|
|
34921
|
+
return this.handleResponse(requestWithPaymaster, decrypted);
|
|
34888
34922
|
}
|
|
34889
34923
|
async handleResponse(request, decrypted) {
|
|
34890
34924
|
var _a, _b, _c, _d, _e;
|
|
@@ -35417,11 +35451,11 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
35417
35451
|
}
|
|
35418
35452
|
|
|
35419
35453
|
/**
|
|
35420
|
-
* Create
|
|
35421
|
-
* @param params - Options to create a
|
|
35454
|
+
* Create Startale AccountSDK instance with EIP-1193 compliant provider
|
|
35455
|
+
* @param params - Options to create a Startale account SDK instance.
|
|
35422
35456
|
* @returns An SDK object with a getProvider method that returns an EIP-1193 compliant provider.
|
|
35423
35457
|
*/
|
|
35424
|
-
function
|
|
35458
|
+
function createStartaleAccountSDK(params) {
|
|
35425
35459
|
var _a, _b, _c, _d, _e, _f;
|
|
35426
35460
|
const options = {
|
|
35427
35461
|
metadata: {
|
|
@@ -35430,7 +35464,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
35430
35464
|
appChainIds: params.appChainIds || [],
|
|
35431
35465
|
},
|
|
35432
35466
|
preference: (_a = params.preference) !== null && _a !== void 0 ? _a : {},
|
|
35433
|
-
|
|
35467
|
+
paymasterOptions: params.paymasterOptions,
|
|
35434
35468
|
};
|
|
35435
35469
|
// ====================================================================
|
|
35436
35470
|
// If we have a toOwnerAccount function, set it in the non-persisted config
|
|
@@ -35917,7 +35951,7 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
35917
35951
|
*/
|
|
35918
35952
|
function createEphemeralSDK(chainId, walletUrl, telemetry = true) {
|
|
35919
35953
|
const appName = typeof window !== 'undefined' ? window.location.origin : 'Base Pay SDK';
|
|
35920
|
-
const sdk =
|
|
35954
|
+
const sdk = createStartaleAccountSDK({
|
|
35921
35955
|
appName: appName,
|
|
35922
35956
|
appChainIds: [chainId],
|
|
35923
35957
|
preference: {
|
|
@@ -36210,13 +36244,13 @@ Please see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-pol
|
|
|
36210
36244
|
// Expose to global window object
|
|
36211
36245
|
if (typeof window !== 'undefined') {
|
|
36212
36246
|
window.base = base;
|
|
36213
|
-
window.
|
|
36247
|
+
window.createStartaleAccountSDK = createStartaleAccountSDK;
|
|
36214
36248
|
}
|
|
36215
36249
|
|
|
36216
36250
|
exports.CHAIN_IDS = CHAIN_IDS;
|
|
36217
36251
|
exports.TOKENS = TOKENS;
|
|
36218
36252
|
exports.base = base;
|
|
36219
|
-
exports.
|
|
36253
|
+
exports.createStartaleAccountSDK = createStartaleAccountSDK;
|
|
36220
36254
|
exports.getCryptoKeyAccount = getCryptoKeyAccount;
|
|
36221
36255
|
exports.getPaymentStatus = getPaymentStatus;
|
|
36222
36256
|
exports.pay = pay;
|