@mycelium-sdk/core 0.1.0 → 1.0.0-alpha.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/LICENSE +55 -0
- package/README.md +1 -1
- package/dist/index.cjs +86 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +208 -179
- package/dist/index.d.ts +208 -179
- package/dist/index.js +85 -90
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Mycelium SDK license
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This project is dual-licensed under the **Apache License 2.0 (Non-Commercial use only)** and a separate **Commercial License**
|
|
6
|
+
|
|
7
|
+
- The **Apache License 2.0 (Non-Commercial)** applies to all **non-commercial** use
|
|
8
|
+
- A **Commercial License** is required for any **for-profit**, **enterprise**, or **SaaS** use
|
|
9
|
+
|
|
10
|
+
## 1. Apache License 2.0 (Non-Commercial)
|
|
11
|
+
|
|
12
|
+
Copyright © 2025 MyceliumSDK
|
|
13
|
+
All rights reserved
|
|
14
|
+
|
|
15
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
you may not use this file except in compliance with the License and the **Non-Commercial Use Restriction** below
|
|
17
|
+
|
|
18
|
+
You may obtain a copy of the License at:
|
|
19
|
+
|
|
20
|
+
> https://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
|
|
22
|
+
### Additional non-commercial use restriction
|
|
23
|
+
|
|
24
|
+
Notwithstanding the terms of the Apache License 2.0,
|
|
25
|
+
**you may use, copy, modify, and distribute this software only for non-commercial purposes**
|
|
26
|
+
|
|
27
|
+
“Non-commercial” means use that:
|
|
28
|
+
|
|
29
|
+
- Does **not** generate revenue or commercial advantage (directly or indirectly)
|
|
30
|
+
- Is **not** used in a product or service offered for sale, rent, or subscription
|
|
31
|
+
- Is **not** used in a business or enterprise setting, except for internal research or testing
|
|
32
|
+
|
|
33
|
+
If you wish to use this software commercially, you must obtain a separate **Commercial License**
|
|
34
|
+
|
|
35
|
+
## 2. Commercial License
|
|
36
|
+
|
|
37
|
+
For commercial use of Mycelium SDK, including but not limited to:
|
|
38
|
+
|
|
39
|
+
- Use in a commercial or for-profit product or service
|
|
40
|
+
- Integration into closed-source or proprietary software
|
|
41
|
+
- SaaS or hosted offerings built upon Mycelium SDK
|
|
42
|
+
- Use by a company, organization, or enterprise for business purposes
|
|
43
|
+
|
|
44
|
+
you must obtain a valid **Commercial License** from the copyright holder.
|
|
45
|
+
|
|
46
|
+
To inquire about a commercial license, please contact:
|
|
47
|
+
|
|
48
|
+
Email: license@mycelium.sh
|
|
49
|
+
Website: [https://mycelium.sh](https://mycelium.sh)
|
|
50
|
+
|
|
51
|
+
## 3. No Warranty
|
|
52
|
+
|
|
53
|
+
This software is provided "as is", without warranty of any kind, express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, or noninfringement
|
|
54
|
+
|
|
55
|
+
In no event shall the authors or copyright holders be liable for any claim, damages, or other liability arising from, out of, or in connection with the software or its use
|
package/README.md
CHANGED
|
@@ -142,4 +142,4 @@ Check the [CONTRIBUTION.md](https://github.com/0xdeval/mycelium-sdk/blob/main/CO
|
|
|
142
142
|
|
|
143
143
|
## License
|
|
144
144
|
|
|
145
|
-
This project is licensed under the dual license - Apache 2.0 + Commercial - see the [LICENSE](https://github.com/0xdeval/mycelium-sdk/blob/main/LICENSE
|
|
145
|
+
This project is licensed under the dual license - Apache 2.0 + Commercial - see the [LICENSE](https://github.com/0xdeval/mycelium-sdk/blob/main/LICENSE)
|
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
DefaultSmartWallet: () => DefaultSmartWallet,
|
|
34
|
+
FundingNamespace: () => FundingNamespace,
|
|
34
35
|
MyceliumSDK: () => MyceliumSDK
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -494,7 +495,7 @@ var DefaultSmartWallet = class extends SmartWallet {
|
|
|
494
495
|
* Funds the smart wallet with the specified amount of the specified token via Coinbase CDP on-ramp service
|
|
495
496
|
*
|
|
496
497
|
* @public
|
|
497
|
-
* @category
|
|
498
|
+
* @category Funding
|
|
498
499
|
*
|
|
499
500
|
* @remarks
|
|
500
501
|
* If Coinbase CDP is not initialized, the method will throw an error. For more details, visit @see {@link https://docs.cdp.coinbase.com/api-reference/v2/rest-api/onramp/create-an-onramp-session}
|
|
@@ -532,7 +533,7 @@ var DefaultSmartWallet = class extends SmartWallet {
|
|
|
532
533
|
* Cashout token from smart wallet to fiat currency via Coinbase CDP off-ramp service
|
|
533
534
|
*
|
|
534
535
|
* @public
|
|
535
|
-
* @category
|
|
536
|
+
* @category Funding
|
|
536
537
|
*
|
|
537
538
|
* @remarks
|
|
538
539
|
* If Coinbase CDP is not initialized, the method will throw an error. For more details, visit @see {@link https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/create-sell-quote}
|
|
@@ -608,6 +609,42 @@ var DefaultSmartWallet = class extends SmartWallet {
|
|
|
608
609
|
}
|
|
609
610
|
};
|
|
610
611
|
|
|
612
|
+
// src/ramp/FundingNamespace.ts
|
|
613
|
+
var FundingNamespace = class {
|
|
614
|
+
constructor(coinbaseCDP) {
|
|
615
|
+
this.coinbaseCDP = null;
|
|
616
|
+
if (!coinbaseCDP) {
|
|
617
|
+
throw new Error(
|
|
618
|
+
"Coinbase CDP is not initialized. Please, provide the configuration in the SDK initialization"
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
this.coinbaseCDP = coinbaseCDP;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Return all supported countries and payment methods for on-ramp by Coinbase CDP
|
|
625
|
+
* @public
|
|
626
|
+
* @category Funding
|
|
627
|
+
*
|
|
628
|
+
* @returns @see {@link RampConfigResponse} with supported countries and payment methods for top-up
|
|
629
|
+
* @throws If API returned an error
|
|
630
|
+
*/
|
|
631
|
+
async getTopUpConfig() {
|
|
632
|
+
return await this.coinbaseCDP.getOnRampConfig();
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Return all supported countries and payment methods for off-ramp by Coinbase CDP
|
|
636
|
+
* @public
|
|
637
|
+
* @category Funding
|
|
638
|
+
*
|
|
639
|
+
*
|
|
640
|
+
* @returns @see {@link RampConfigResponse} with supported countries and payment methods for cash out
|
|
641
|
+
* @throws If API returned an error
|
|
642
|
+
*/
|
|
643
|
+
async getCashOutConfig() {
|
|
644
|
+
return await this.coinbaseCDP.getOffRampConfig();
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
|
|
611
648
|
// src/tools/ChainManager.ts
|
|
612
649
|
var import_viem5 = require("viem");
|
|
613
650
|
var import_account_abstraction2 = require("viem/account-abstraction");
|
|
@@ -913,32 +950,6 @@ var WalletNamespace = class {
|
|
|
913
950
|
constructor(provider) {
|
|
914
951
|
this.provider = provider;
|
|
915
952
|
}
|
|
916
|
-
/**
|
|
917
|
-
* Direct access to the underlying embedded wallet provider
|
|
918
|
-
*
|
|
919
|
-
* @public
|
|
920
|
-
* @category Providers
|
|
921
|
-
* @remarks
|
|
922
|
-
* Useful when you need advanced functionality beyond the unified namespace. By default, you should use the unified namespace
|
|
923
|
-
*
|
|
924
|
-
* @returns The configured embedded wallet provider instance
|
|
925
|
-
*/
|
|
926
|
-
get embeddedWalletProvider() {
|
|
927
|
-
return this.provider.embeddedWalletProvider;
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* Direct access to the underlying smart wallet provider
|
|
931
|
-
*
|
|
932
|
-
* @public
|
|
933
|
-
* @category Providers
|
|
934
|
-
* @remarks
|
|
935
|
-
* Useful when you need advanced functionality beyond the unified namespace. By default, you should use the unified namespace
|
|
936
|
-
*
|
|
937
|
-
* @returns The configured smart wallet provider instance
|
|
938
|
-
*/
|
|
939
|
-
get smartWalletProvider() {
|
|
940
|
-
return this.provider.smartWalletProvider;
|
|
941
|
-
}
|
|
942
953
|
/**
|
|
943
954
|
* Creates an embedded wallet
|
|
944
955
|
*
|
|
@@ -971,7 +982,7 @@ var WalletNamespace = class {
|
|
|
971
982
|
return this.provider.createSmartWallet(params);
|
|
972
983
|
}
|
|
973
984
|
/**
|
|
974
|
-
*
|
|
985
|
+
* A unified a web3 account: creates a smart wallet with an embedded wallet as signer
|
|
975
986
|
*
|
|
976
987
|
* @public
|
|
977
988
|
* @category Creation
|
|
@@ -985,11 +996,11 @@ var WalletNamespace = class {
|
|
|
985
996
|
* @param params.nonce Optional nonce/salt for deterministic address generation (defaults to 0)
|
|
986
997
|
* @returns Promise that resolves to the created {@link SmartWallet}
|
|
987
998
|
*/
|
|
988
|
-
async
|
|
989
|
-
return this.provider.
|
|
999
|
+
async createAccount(params) {
|
|
1000
|
+
return this.provider.createAccount(params);
|
|
990
1001
|
}
|
|
991
1002
|
/**
|
|
992
|
-
* Gets a smart wallet using an embedded wallet as the signer
|
|
1003
|
+
* Gets a unified web3 account: a smart wallet using an embedded wallet as the signer
|
|
993
1004
|
*
|
|
994
1005
|
* @public
|
|
995
1006
|
* @category Retrieval
|
|
@@ -1007,8 +1018,8 @@ var WalletNamespace = class {
|
|
|
1007
1018
|
* @returns Promise that resolves to the {@link SmartWallet}
|
|
1008
1019
|
* @throws Error if the embedded wallet cannot be found
|
|
1009
1020
|
*/
|
|
1010
|
-
async
|
|
1011
|
-
return this.provider.
|
|
1021
|
+
async getAccount(params) {
|
|
1022
|
+
return this.provider.getAccount(params);
|
|
1012
1023
|
}
|
|
1013
1024
|
/**
|
|
1014
1025
|
* Gets an existing embedded wallet by ID
|
|
@@ -1164,18 +1175,6 @@ var DefaultSmartWalletProvider = class extends SmartWalletProvider {
|
|
|
1164
1175
|
ownerIndex
|
|
1165
1176
|
);
|
|
1166
1177
|
}
|
|
1167
|
-
/**
|
|
1168
|
-
* Funds a wallet via a faucet if supported by the selected chain
|
|
1169
|
-
*
|
|
1170
|
-
* @internal
|
|
1171
|
-
* @category Funding
|
|
1172
|
-
* @remarks
|
|
1173
|
-
* Placeholder for testnet faucet integration
|
|
1174
|
-
*
|
|
1175
|
-
* @returns Future transaction hash or provider response
|
|
1176
|
-
*/
|
|
1177
|
-
fundViaFaucet() {
|
|
1178
|
-
}
|
|
1179
1178
|
};
|
|
1180
1179
|
|
|
1181
1180
|
// src/wallet/WalletProvider.ts
|
|
@@ -1239,9 +1238,12 @@ var WalletProvider = class {
|
|
|
1239
1238
|
* @param params.nonce Optional salt/nonce for deterministic address calculation (defaults to 0)
|
|
1240
1239
|
* @returns Promise that resolves to the created {@link SmartWallet}
|
|
1241
1240
|
*/
|
|
1242
|
-
async
|
|
1241
|
+
async createAccount(params) {
|
|
1243
1242
|
const { owners: ownersParam, embeddedWalletIndex, nonce } = params || {};
|
|
1244
1243
|
const embeddedWallet = await this.embeddedWalletProvider.createWallet();
|
|
1244
|
+
if (!embeddedWallet.walletId) {
|
|
1245
|
+
throw new Error("Failed to create embedded wallet. No wallet ID returned");
|
|
1246
|
+
}
|
|
1245
1247
|
const account = await embeddedWallet.account();
|
|
1246
1248
|
let owners;
|
|
1247
1249
|
if (ownersParam) {
|
|
@@ -1251,14 +1253,18 @@ var WalletProvider = class {
|
|
|
1251
1253
|
} else {
|
|
1252
1254
|
owners = [embeddedWallet.address];
|
|
1253
1255
|
}
|
|
1254
|
-
|
|
1256
|
+
const smartWallet = await this.smartWalletProvider.createWallet({
|
|
1255
1257
|
owners,
|
|
1256
1258
|
signer: account,
|
|
1257
1259
|
nonce
|
|
1258
1260
|
});
|
|
1261
|
+
return {
|
|
1262
|
+
embeddedWalletId: embeddedWallet.walletId,
|
|
1263
|
+
smartWallet
|
|
1264
|
+
};
|
|
1259
1265
|
}
|
|
1260
1266
|
/**
|
|
1261
|
-
* Gets a smart wallet using an embedded wallet as the signer
|
|
1267
|
+
* Gets a unified web3 account: a smart wallet using an embedded wallet as the signer
|
|
1262
1268
|
*
|
|
1263
1269
|
* @internal
|
|
1264
1270
|
* @remarks
|
|
@@ -1275,7 +1281,7 @@ var WalletProvider = class {
|
|
|
1275
1281
|
* @returns Promise that resolves to the {@link SmartWallet}
|
|
1276
1282
|
* @throws Error if the embedded wallet cannot be found
|
|
1277
1283
|
*/
|
|
1278
|
-
async
|
|
1284
|
+
async getAccount(params) {
|
|
1279
1285
|
const { walletId, deploymentOwners, walletAddress } = params;
|
|
1280
1286
|
const embeddedWallet = await this.embeddedWalletProvider.getWallet({
|
|
1281
1287
|
walletId
|
|
@@ -2342,6 +2348,15 @@ var MyceliumSDK = class {
|
|
|
2342
2348
|
* @see MyceliumSDKConfig
|
|
2343
2349
|
*/
|
|
2344
2350
|
constructor(config) {
|
|
2351
|
+
/**
|
|
2352
|
+
* Ramp namespace to manage ramp operations. Methods are available on {@link RampNamespace}
|
|
2353
|
+
* @internal
|
|
2354
|
+
* @remarks
|
|
2355
|
+
* If the Coinbase CDP configuration is not provided, the ramp functionality will be disabled.
|
|
2356
|
+
* Calling the respective method will throw an error
|
|
2357
|
+
* @category Tools
|
|
2358
|
+
*/
|
|
2359
|
+
this.fundingNamespace = null;
|
|
2345
2360
|
/**
|
|
2346
2361
|
* Coinbase CDP instance to Coinbase related and onchain operations using Coinbase CDP API
|
|
2347
2362
|
* @remarks
|
|
@@ -2350,46 +2365,6 @@ var MyceliumSDK = class {
|
|
|
2350
2365
|
* @internal
|
|
2351
2366
|
*/
|
|
2352
2367
|
this.coinbaseCDP = null;
|
|
2353
|
-
/**
|
|
2354
|
-
* Coinbase CDP configuration methods for ramp operations
|
|
2355
|
-
* @public
|
|
2356
|
-
* @category Tools
|
|
2357
|
-
*/
|
|
2358
|
-
this.rampConfig = {
|
|
2359
|
-
/**
|
|
2360
|
-
* Return all supported countries and payment methods for on-ramp by Coinbase CDP
|
|
2361
|
-
* @public
|
|
2362
|
-
* @category Ramp
|
|
2363
|
-
*
|
|
2364
|
-
* @returns @see {@link RampConfigResponse} with supported countries and payment methods for top-up
|
|
2365
|
-
* @throws If API returned an error
|
|
2366
|
-
*/
|
|
2367
|
-
getTopUpConfig: async () => {
|
|
2368
|
-
if (!this.coinbaseCDP) {
|
|
2369
|
-
throw new Error(
|
|
2370
|
-
"Coinbase CDP is not initialized. Please, provide the configuration in the SDK initialization"
|
|
2371
|
-
);
|
|
2372
|
-
}
|
|
2373
|
-
return await this.coinbaseCDP.getOnRampConfig();
|
|
2374
|
-
},
|
|
2375
|
-
/**
|
|
2376
|
-
* Return all supported countries and payment methods for off-ramp by Coinbase CDP
|
|
2377
|
-
* @public
|
|
2378
|
-
* @category Ramp
|
|
2379
|
-
*
|
|
2380
|
-
*
|
|
2381
|
-
* @returns @see {@link RampConfigResponse} with supported countries and payment methods for cash out
|
|
2382
|
-
* @throws If API returned an error
|
|
2383
|
-
*/
|
|
2384
|
-
getCashOutConfig: async () => {
|
|
2385
|
-
if (!this.coinbaseCDP) {
|
|
2386
|
-
throw new Error(
|
|
2387
|
-
"Coinbase CDP is not initialized. Please, provide the configuration in the SDK initialization"
|
|
2388
|
-
);
|
|
2389
|
-
}
|
|
2390
|
-
return await this.coinbaseCDP.getOffRampConfig();
|
|
2391
|
-
}
|
|
2392
|
-
};
|
|
2393
2368
|
this._chainManager = new ChainManager(
|
|
2394
2369
|
config.chain || {
|
|
2395
2370
|
chainId: import_chains7.base.id,
|
|
@@ -2410,6 +2385,7 @@ var MyceliumSDK = class {
|
|
|
2410
2385
|
config.integratorId,
|
|
2411
2386
|
this.chainManager
|
|
2412
2387
|
);
|
|
2388
|
+
this.fundingNamespace = new FundingNamespace(this.coinbaseCDP);
|
|
2413
2389
|
}
|
|
2414
2390
|
const protocolsRouterConfig = config.protocolsRouterConfig || {
|
|
2415
2391
|
riskLevel: "low"
|
|
@@ -2420,6 +2396,8 @@ var MyceliumSDK = class {
|
|
|
2420
2396
|
/**
|
|
2421
2397
|
* Returns the chain manager instance for multi-chain operations
|
|
2422
2398
|
* @public
|
|
2399
|
+
* @remarks
|
|
2400
|
+
* More about methods in {@link ChainManager}
|
|
2423
2401
|
* @category Tools
|
|
2424
2402
|
*
|
|
2425
2403
|
* @returns ChainManager instance of the type {@link ChainManager}
|
|
@@ -2427,6 +2405,23 @@ var MyceliumSDK = class {
|
|
|
2427
2405
|
get chainManager() {
|
|
2428
2406
|
return this._chainManager;
|
|
2429
2407
|
}
|
|
2408
|
+
/**
|
|
2409
|
+
* Returns a funding namespace to manage top ups & cash outs configurations
|
|
2410
|
+
* @public
|
|
2411
|
+
* @remarks
|
|
2412
|
+
* More about methods in {@link FundingNamespace}
|
|
2413
|
+
* @category Tools
|
|
2414
|
+
*
|
|
2415
|
+
* @returns Funding namespace of the type {@link FundingNamespace}
|
|
2416
|
+
*/
|
|
2417
|
+
get funding() {
|
|
2418
|
+
if (!this.fundingNamespace) {
|
|
2419
|
+
throw new Error(
|
|
2420
|
+
"Ramp namespace is not initialized. Please, provide the configuration in the SDK initialization"
|
|
2421
|
+
);
|
|
2422
|
+
}
|
|
2423
|
+
return this.fundingNamespace;
|
|
2424
|
+
}
|
|
2430
2425
|
/**
|
|
2431
2426
|
* Recommends and initializes a protocol based on router settings
|
|
2432
2427
|
*
|
|
@@ -2495,6 +2490,7 @@ var MyceliumSDK = class {
|
|
|
2495
2490
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2496
2491
|
0 && (module.exports = {
|
|
2497
2492
|
DefaultSmartWallet,
|
|
2493
|
+
FundingNamespace,
|
|
2498
2494
|
MyceliumSDK
|
|
2499
2495
|
});
|
|
2500
2496
|
//# sourceMappingURL=index.cjs.map
|