@dynamic-labs/stellar 4.63.0 → 4.64.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 +25 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connectors/DynamicWaasStellarConnector/DynamicWaasStellarConnector.d.ts +6 -0
- package/src/connectors/StellarWalletConnector/StellarWalletConnector.cjs +31 -8
- package/src/connectors/StellarWalletConnector/StellarWalletConnector.js +31 -8
- package/src/index.cjs +3 -3
- package/src/index.d.ts +2 -1
- package/src/index.js +3 -2
- package/src/utils/buildTrustlineTransaction.cjs +30 -0
- package/src/utils/buildTrustlineTransaction.d.ts +17 -0
- package/src/utils/buildTrustlineTransaction.js +26 -0
- package/src/utils/index.d.ts +1 -0
- package/src/wallet/StellarWallet.cjs +32 -0
- package/src/wallet/StellarWallet.d.ts +16 -0
- package/src/wallet/StellarWallet.js +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.64.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.63.1...v4.64.0) (2026-02-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add addTrustline method to the stellar wallet ([#10510](https://github.com/dynamic-labs/dynamic-auth/issues/10510)) ([e8690e8](https://github.com/dynamic-labs/dynamic-auth/commit/e8690e821dfe867355618d970380568487c3dd36))
|
|
8
|
+
|
|
9
|
+
### [4.63.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.63.0...v4.63.1) (2026-02-24)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add elevated access token to WaaS export ([#10481](https://github.com/dynamic-labs/dynamic-auth/issues/10481)) ([9a3c6a6](https://github.com/dynamic-labs/dynamic-auth/commit/9a3c6a6eaa4bd7ced5aeb873fe7872717d0e25d9))
|
|
15
|
+
* add multi-wallet delegation support with React parity ([#10450](https://github.com/dynamic-labs/dynamic-auth/issues/10450)) ([e4d5135](https://github.com/dynamic-labs/dynamic-auth/commit/e4d5135c50595c022dfb02da2d9f05a389c0ee09))
|
|
16
|
+
* add Stellar chain support with balance fetching and network mapping ([#10494](https://github.com/dynamic-labs/dynamic-auth/issues/10494)) ([f12553c](https://github.com/dynamic-labs/dynamic-auth/commit/f12553ce864a56a75f87d1d55c087e1fc9378cc6))
|
|
17
|
+
* add Stellar WaaS transaction signing and broadcast UI ([#10495](https://github.com/dynamic-labs/dynamic-auth/issues/10495)) ([f87a860](https://github.com/dynamic-labs/dynamic-auth/commit/f87a860f59cdf5b0c4f99586c61e60186efc19f2))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* cancel authFlowClose timeout when navigation occurs during delay ([#10487](https://github.com/dynamic-labs/dynamic-auth/issues/10487)) ([aef92b4](https://github.com/dynamic-labs/dynamic-auth/commit/aef92b4a80827c517819cc63414acdf3e9ad7b05))
|
|
23
|
+
* **e2e:** update gating test to expect user:basic scope ([#10505](https://github.com/dynamic-labs/dynamic-auth/issues/10505)) ([56f449a](https://github.com/dynamic-labs/dynamic-auth/commit/56f449a282f37b33d365d60380c7a68c1cf5eced)), closes [dynamic-labs/redcoast#8339](https://github.com/dynamic-labs/redcoast/issues/8339)
|
|
24
|
+
* use selected network for Horizon server and include WaaS connector in StellarWalletConnectors ([#10493](https://github.com/dynamic-labs/dynamic-auth/issues/10493)) ([f340c09](https://github.com/dynamic-labs/dynamic-auth/commit/f340c094f08afb39829f2d90db2ec665a69ba469))
|
|
25
|
+
* **waas:** normalize SOL to SVM chain name when looking up WaaS connector ([#10506](https://github.com/dynamic-labs/dynamic-auth/issues/10506)) ([102d314](https://github.com/dynamic-labs/dynamic-auth/commit/102d3142d65d0e67338884affc736e5151a8e296))
|
|
26
|
+
|
|
2
27
|
## [4.63.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.62.0...v4.63.0) (2026-02-24)
|
|
3
28
|
|
|
4
29
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/stellar",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.64.0",
|
|
4
4
|
"description": "A React SDK for implementing Stellar wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@dynamic-labs/sdk-api-core": "0.0.875",
|
|
22
22
|
"@stellar/stellar-sdk": "14.4.3",
|
|
23
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
24
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
23
|
+
"@dynamic-labs/wallet-connector-core": "4.64.0",
|
|
24
|
+
"@dynamic-labs/assert-package-version": "4.64.0",
|
|
25
25
|
"@lobstrco/signer-extension-api": "2.0.0",
|
|
26
26
|
"@stellar/freighter-api": "6.0.1",
|
|
27
|
-
"@dynamic-labs/logger": "4.
|
|
28
|
-
"@dynamic-labs/types": "4.
|
|
29
|
-
"@dynamic-labs/utils": "4.
|
|
30
|
-
"@dynamic-labs/waas": "4.
|
|
31
|
-
"@dynamic-labs/wallet-book": "4.
|
|
27
|
+
"@dynamic-labs/logger": "4.64.0",
|
|
28
|
+
"@dynamic-labs/types": "4.64.0",
|
|
29
|
+
"@dynamic-labs/utils": "4.64.0",
|
|
30
|
+
"@dynamic-labs/waas": "4.64.0",
|
|
31
|
+
"@dynamic-labs/wallet-book": "4.64.0",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {}
|
|
@@ -19,6 +19,9 @@ declare const DynamicWaasStellarConnector_base: (abstract new (...args: any[]) =
|
|
|
19
19
|
} | undefined) => Promise<string | undefined>) | undefined;
|
|
20
20
|
getWalletPassword?: import("@dynamic-labs/wallet-connector-core").GetWalletPasswordFn | undefined;
|
|
21
21
|
getAuthToken?: (() => string) | undefined;
|
|
22
|
+
getElevatedAccessToken?: ((props: {
|
|
23
|
+
scope: import("@dynamic-labs/sdk-api-core").TokenScope;
|
|
24
|
+
}) => Promise<string | undefined>) | undefined;
|
|
22
25
|
environmentId?: string | undefined;
|
|
23
26
|
baseApiUrl?: string | undefined;
|
|
24
27
|
relayUrl?: string | undefined;
|
|
@@ -34,6 +37,9 @@ declare const DynamicWaasStellarConnector_base: (abstract new (...args: any[]) =
|
|
|
34
37
|
setGetMfaTokenFunction(getMfaToken: (props?: {
|
|
35
38
|
mfaAction?: MFAAction | undefined;
|
|
36
39
|
} | undefined) => Promise<string | undefined>): void;
|
|
40
|
+
setGetElevatedAccessTokenFunction(getElevatedAccessToken: (params: {
|
|
41
|
+
scope: import("@dynamic-labs/sdk-api-core").TokenScope;
|
|
42
|
+
}) => Promise<string | undefined>): void;
|
|
37
43
|
setGetWalletPasswordFunction(getWalletPassword: import("@dynamic-labs/wallet-connector-core").GetWalletPasswordFn): void;
|
|
38
44
|
getPasswordIfNeeded({ accountAddress, }: {
|
|
39
45
|
accountAddress: string;
|
|
@@ -50,8 +50,8 @@ class StellarWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
50
50
|
return this.stellarNetworks.length > 1;
|
|
51
51
|
}
|
|
52
52
|
getSelectedNetwork() {
|
|
53
|
-
var _a;
|
|
54
|
-
return (_a = this.stellarNetworks) === null ||
|
|
53
|
+
var _a, _b;
|
|
54
|
+
return (_a = this.selectedNetwork) !== null && _a !== void 0 ? _a : (_b = this.stellarNetworks) === null || _b === void 0 ? void 0 : _b[0];
|
|
55
55
|
}
|
|
56
56
|
switchNetwork(_a) {
|
|
57
57
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ networkChainId, }) {
|
|
@@ -67,22 +67,44 @@ class StellarWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
67
67
|
}
|
|
68
68
|
getNetwork() {
|
|
69
69
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
var _a;
|
|
70
71
|
if (!this.stellarNetworks.length) {
|
|
71
72
|
return undefined;
|
|
72
73
|
}
|
|
74
|
+
// If selectedNetwork is already set, return its chainId
|
|
73
75
|
if (this.selectedNetwork) {
|
|
74
|
-
return this.selectedNetwork.chainId
|
|
76
|
+
return String(this.selectedNetwork.chainId);
|
|
75
77
|
}
|
|
78
|
+
// Detect network from address (needed after page reload)
|
|
76
79
|
const address = yield this.getAddress();
|
|
77
80
|
if (!address) {
|
|
78
81
|
return undefined;
|
|
79
82
|
}
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
83
|
+
const detectedChainId = yield getNetworkFromAddress.getNetworkFromAddress(address, this.stellarNetworks[0]);
|
|
84
|
+
if (!detectedChainId) {
|
|
82
85
|
return undefined;
|
|
83
86
|
}
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
// Find and set the selectedNetwork based on detected chainId
|
|
88
|
+
this.selectedNetwork = this.stellarNetworks.find((n) => n.chainId.toString() === detectedChainId);
|
|
89
|
+
// If no exact match found, determine if it's testnet or mainnet based on the chainId
|
|
90
|
+
// and select the appropriate network from stellarNetworks
|
|
91
|
+
if (!this.selectedNetwork) {
|
|
92
|
+
// Testnet chainId starts with 'cee0302d', mainnet with '7ac33997'
|
|
93
|
+
const isTestnet = detectedChainId.startsWith('cee0302d');
|
|
94
|
+
this.selectedNetwork = this.stellarNetworks.find((n) => {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
return isTestnet
|
|
97
|
+
? (_a = n.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('testnet')
|
|
98
|
+
: !((_b = n.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('testnet'));
|
|
99
|
+
});
|
|
100
|
+
// If still no match, use the first network
|
|
101
|
+
if (!this.selectedNetwork) {
|
|
102
|
+
[this.selectedNetwork] = this.stellarNetworks;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Return chainId (the hash) for network validation
|
|
106
|
+
// This matches the chainId/networkId in the enabled networks from the API
|
|
107
|
+
return String((_a = this.selectedNetwork) === null || _a === void 0 ? void 0 : _a.chainId);
|
|
86
108
|
});
|
|
87
109
|
}
|
|
88
110
|
/**
|
|
@@ -221,7 +243,8 @@ class StellarWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
221
243
|
getHorizonServer() {
|
|
222
244
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
223
245
|
var _a, _b;
|
|
224
|
-
const
|
|
246
|
+
const network = (_a = this.selectedNetwork) !== null && _a !== void 0 ? _a : this.stellarNetworks[0];
|
|
247
|
+
const url = ((_b = network === null || network === void 0 ? void 0 : network.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('testnet'))
|
|
225
248
|
? HORIZON_TESTNET_URL
|
|
226
249
|
: HORIZON_MAINNET_URL;
|
|
227
250
|
return new stellarSdk.Horizon.Server(url);
|
|
@@ -46,8 +46,8 @@ class StellarWalletConnector extends WalletConnectorBase {
|
|
|
46
46
|
return this.stellarNetworks.length > 1;
|
|
47
47
|
}
|
|
48
48
|
getSelectedNetwork() {
|
|
49
|
-
var _a;
|
|
50
|
-
return (_a = this.stellarNetworks) === null ||
|
|
49
|
+
var _a, _b;
|
|
50
|
+
return (_a = this.selectedNetwork) !== null && _a !== void 0 ? _a : (_b = this.stellarNetworks) === null || _b === void 0 ? void 0 : _b[0];
|
|
51
51
|
}
|
|
52
52
|
switchNetwork(_a) {
|
|
53
53
|
return __awaiter(this, arguments, void 0, function* ({ networkChainId, }) {
|
|
@@ -63,22 +63,44 @@ class StellarWalletConnector extends WalletConnectorBase {
|
|
|
63
63
|
}
|
|
64
64
|
getNetwork() {
|
|
65
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
var _a;
|
|
66
67
|
if (!this.stellarNetworks.length) {
|
|
67
68
|
return undefined;
|
|
68
69
|
}
|
|
70
|
+
// If selectedNetwork is already set, return its chainId
|
|
69
71
|
if (this.selectedNetwork) {
|
|
70
|
-
return this.selectedNetwork.chainId
|
|
72
|
+
return String(this.selectedNetwork.chainId);
|
|
71
73
|
}
|
|
74
|
+
// Detect network from address (needed after page reload)
|
|
72
75
|
const address = yield this.getAddress();
|
|
73
76
|
if (!address) {
|
|
74
77
|
return undefined;
|
|
75
78
|
}
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
79
|
+
const detectedChainId = yield getNetworkFromAddress(address, this.stellarNetworks[0]);
|
|
80
|
+
if (!detectedChainId) {
|
|
78
81
|
return undefined;
|
|
79
82
|
}
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
// Find and set the selectedNetwork based on detected chainId
|
|
84
|
+
this.selectedNetwork = this.stellarNetworks.find((n) => n.chainId.toString() === detectedChainId);
|
|
85
|
+
// If no exact match found, determine if it's testnet or mainnet based on the chainId
|
|
86
|
+
// and select the appropriate network from stellarNetworks
|
|
87
|
+
if (!this.selectedNetwork) {
|
|
88
|
+
// Testnet chainId starts with 'cee0302d', mainnet with '7ac33997'
|
|
89
|
+
const isTestnet = detectedChainId.startsWith('cee0302d');
|
|
90
|
+
this.selectedNetwork = this.stellarNetworks.find((n) => {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
return isTestnet
|
|
93
|
+
? (_a = n.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('testnet')
|
|
94
|
+
: !((_b = n.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('testnet'));
|
|
95
|
+
});
|
|
96
|
+
// If still no match, use the first network
|
|
97
|
+
if (!this.selectedNetwork) {
|
|
98
|
+
[this.selectedNetwork] = this.stellarNetworks;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Return chainId (the hash) for network validation
|
|
102
|
+
// This matches the chainId/networkId in the enabled networks from the API
|
|
103
|
+
return String((_a = this.selectedNetwork) === null || _a === void 0 ? void 0 : _a.chainId);
|
|
82
104
|
});
|
|
83
105
|
}
|
|
84
106
|
/**
|
|
@@ -217,7 +239,8 @@ class StellarWalletConnector extends WalletConnectorBase {
|
|
|
217
239
|
getHorizonServer() {
|
|
218
240
|
return __awaiter(this, void 0, void 0, function* () {
|
|
219
241
|
var _a, _b;
|
|
220
|
-
const
|
|
242
|
+
const network = (_a = this.selectedNetwork) !== null && _a !== void 0 ? _a : this.stellarNetworks[0];
|
|
243
|
+
const url = ((_b = network === null || network === void 0 ? void 0 : network.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('testnet'))
|
|
221
244
|
? HORIZON_TESTNET_URL
|
|
222
245
|
: HORIZON_MAINNET_URL;
|
|
223
246
|
return new Horizon.Server(url);
|
package/src/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
7
7
|
var _package = require('../package.cjs');
|
|
8
|
+
var index = require('./connectors/DynamicWaasStellarConnector/index.cjs');
|
|
8
9
|
var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors.cjs');
|
|
9
10
|
var StellarWallet = require('./wallet/StellarWallet.cjs');
|
|
10
11
|
var isStellarWallet = require('./wallet/isStellarWallet/isStellarWallet.cjs');
|
|
@@ -14,7 +15,6 @@ require('@stellar/stellar-sdk');
|
|
|
14
15
|
var getNetworkFromAddress = require('./utils/getNetworkFromAddress.cjs');
|
|
15
16
|
require('../_virtual/_tslib.cjs');
|
|
16
17
|
require('@dynamic-labs/utils');
|
|
17
|
-
var index = require('./connectors/DynamicWaasStellarConnector/index.cjs');
|
|
18
18
|
var DynamicWaasStellarConnector = require('./connectors/DynamicWaasStellarConnector/DynamicWaasStellarConnector.cjs');
|
|
19
19
|
|
|
20
20
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/stellar', _package.version);
|
|
@@ -22,14 +22,14 @@ assertPackageVersion.assertPackageVersion('@dynamic-labs/stellar', _package.vers
|
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
23
|
const StellarWalletConnectors = (_props) => [
|
|
24
24
|
...fetchInjectedWalletConnectors.fetchInjectedWalletConnectors(),
|
|
25
|
-
|
|
25
|
+
DynamicWaasStellarConnector.DynamicWaasStellarConnector,
|
|
26
26
|
];
|
|
27
27
|
|
|
28
|
+
exports.DynamicWaasStellarConnectors = index.DynamicWaasStellarConnectors;
|
|
28
29
|
exports.StellarWallet = StellarWallet.StellarWallet;
|
|
29
30
|
exports.isStellarWallet = isStellarWallet.isStellarWallet;
|
|
30
31
|
exports.StellarWalletConnector = StellarWalletConnector.StellarWalletConnector;
|
|
31
32
|
exports.StellarLocalStorageCache = StellarLocalStorageCache.StellarLocalStorageCache;
|
|
32
33
|
exports.getNetworkFromAddress = getNetworkFromAddress.getNetworkFromAddress;
|
|
33
|
-
exports.DynamicWaasStellarConnectors = index.DynamicWaasStellarConnectors;
|
|
34
34
|
exports.DynamicWaasStellarConnector = DynamicWaasStellarConnector.DynamicWaasStellarConnector;
|
|
35
35
|
exports.StellarWalletConnectors = StellarWalletConnectors;
|
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { DynamicWaasStellarConnector } from './connectors/DynamicWaasStellarConnector';
|
|
1
2
|
export { StellarWallet, isStellarWallet } from './wallet';
|
|
2
3
|
export { StellarWalletConnector } from './connectors/StellarWalletConnector';
|
|
3
4
|
export { StellarLocalStorageCache, type IStellarSessionCache, type StellarConnectedAccount, } from './StellarLocalStorageCache';
|
|
4
5
|
export type { IStellarProvider, StellarConnectionResult, StellarEventCallback, StellarMethodName, StellarNetworkName, StellarProviderEvent, StellarSendBalanceProps, StellarSignTransactionOptions, StellarWalletConnectorProps, } from './types';
|
|
5
6
|
export { getNetworkFromAddress } from './utils';
|
|
6
|
-
export declare const StellarWalletConnectors: (_props?: unknown) => import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor[];
|
|
7
|
+
export declare const StellarWalletConnectors: (_props?: unknown) => (import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor | typeof DynamicWaasStellarConnector)[];
|
|
7
8
|
export { DynamicWaasStellarConnector, DynamicWaasStellarConnectors, } from './connectors/DynamicWaasStellarConnector';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
3
3
|
import { version } from '../package.js';
|
|
4
|
+
export { DynamicWaasStellarConnectors } from './connectors/DynamicWaasStellarConnector/index.js';
|
|
4
5
|
import { fetchInjectedWalletConnectors } from './injected/fetchInjectedWalletConnectors.js';
|
|
5
6
|
export { StellarWallet } from './wallet/StellarWallet.js';
|
|
6
7
|
export { isStellarWallet } from './wallet/isStellarWallet/isStellarWallet.js';
|
|
@@ -10,7 +11,7 @@ import '@stellar/stellar-sdk';
|
|
|
10
11
|
export { getNetworkFromAddress } from './utils/getNetworkFromAddress.js';
|
|
11
12
|
import '../_virtual/_tslib.js';
|
|
12
13
|
import '@dynamic-labs/utils';
|
|
13
|
-
|
|
14
|
+
import { DynamicWaasStellarConnector } from './connectors/DynamicWaasStellarConnector/DynamicWaasStellarConnector.js';
|
|
14
15
|
export { DynamicWaasStellarConnector } from './connectors/DynamicWaasStellarConnector/DynamicWaasStellarConnector.js';
|
|
15
16
|
|
|
16
17
|
assertPackageVersion('@dynamic-labs/stellar', version);
|
|
@@ -18,7 +19,7 @@ assertPackageVersion('@dynamic-labs/stellar', version);
|
|
|
18
19
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
20
|
const StellarWalletConnectors = (_props) => [
|
|
20
21
|
...fetchInjectedWalletConnectors(),
|
|
21
|
-
|
|
22
|
+
DynamicWaasStellarConnector,
|
|
22
23
|
];
|
|
23
24
|
|
|
24
25
|
export { StellarWalletConnectors };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var stellarSdk = require('@stellar/stellar-sdk');
|
|
7
|
+
|
|
8
|
+
const DEFAULT_TIMEOUT = 180;
|
|
9
|
+
/**
|
|
10
|
+
* Builds a Stellar change trust transaction to add or modify a trustline.
|
|
11
|
+
*
|
|
12
|
+
* @param params - Transaction parameters
|
|
13
|
+
* @param params.asset - The asset to establish a trustline for
|
|
14
|
+
* @param params.limit - Optional maximum balance limit. Defaults to max if not provided
|
|
15
|
+
* @param params.networkPassphrase - The network passphrase
|
|
16
|
+
* @param params.sourceAccount - The source account establishing the trustline
|
|
17
|
+
* @returns A built Stellar transaction
|
|
18
|
+
*/
|
|
19
|
+
const buildTrustlineTransaction = (params) => {
|
|
20
|
+
const { asset, limit, networkPassphrase, sourceAccount } = params;
|
|
21
|
+
return new stellarSdk.TransactionBuilder(sourceAccount, {
|
|
22
|
+
fee: stellarSdk.BASE_FEE,
|
|
23
|
+
networkPassphrase,
|
|
24
|
+
})
|
|
25
|
+
.addOperation(stellarSdk.Operation.changeTrust({ asset, limit }))
|
|
26
|
+
.setTimeout(DEFAULT_TIMEOUT)
|
|
27
|
+
.build();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.buildTrustlineTransaction = buildTrustlineTransaction;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Asset, type Horizon, Transaction } from '@stellar/stellar-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Builds a Stellar change trust transaction to add or modify a trustline.
|
|
4
|
+
*
|
|
5
|
+
* @param params - Transaction parameters
|
|
6
|
+
* @param params.asset - The asset to establish a trustline for
|
|
7
|
+
* @param params.limit - Optional maximum balance limit. Defaults to max if not provided
|
|
8
|
+
* @param params.networkPassphrase - The network passphrase
|
|
9
|
+
* @param params.sourceAccount - The source account establishing the trustline
|
|
10
|
+
* @returns A built Stellar transaction
|
|
11
|
+
*/
|
|
12
|
+
export declare const buildTrustlineTransaction: (params: {
|
|
13
|
+
asset: Asset;
|
|
14
|
+
limit?: string;
|
|
15
|
+
networkPassphrase: string;
|
|
16
|
+
sourceAccount: Horizon.AccountResponse;
|
|
17
|
+
}) => Transaction;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { TransactionBuilder, BASE_FEE, Operation } from '@stellar/stellar-sdk';
|
|
3
|
+
|
|
4
|
+
const DEFAULT_TIMEOUT = 180;
|
|
5
|
+
/**
|
|
6
|
+
* Builds a Stellar change trust transaction to add or modify a trustline.
|
|
7
|
+
*
|
|
8
|
+
* @param params - Transaction parameters
|
|
9
|
+
* @param params.asset - The asset to establish a trustline for
|
|
10
|
+
* @param params.limit - Optional maximum balance limit. Defaults to max if not provided
|
|
11
|
+
* @param params.networkPassphrase - The network passphrase
|
|
12
|
+
* @param params.sourceAccount - The source account establishing the trustline
|
|
13
|
+
* @returns A built Stellar transaction
|
|
14
|
+
*/
|
|
15
|
+
const buildTrustlineTransaction = (params) => {
|
|
16
|
+
const { asset, limit, networkPassphrase, sourceAccount } = params;
|
|
17
|
+
return new TransactionBuilder(sourceAccount, {
|
|
18
|
+
fee: BASE_FEE,
|
|
19
|
+
networkPassphrase,
|
|
20
|
+
})
|
|
21
|
+
.addOperation(Operation.changeTrust({ asset, limit }))
|
|
22
|
+
.setTimeout(DEFAULT_TIMEOUT)
|
|
23
|
+
.build();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { buildTrustlineTransaction };
|
package/src/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { buildPaymentTransaction } from './buildPaymentTransaction';
|
|
2
|
+
export { buildTrustlineTransaction } from './buildTrustlineTransaction';
|
|
2
3
|
export { checkTrustline } from './checkTrustline';
|
|
3
4
|
export { createPaymentAsset } from './createPaymentAsset';
|
|
4
5
|
export { createTransactionMemo } from './createTransactionMemo';
|
|
@@ -7,6 +7,7 @@ var _tslib = require('../../_virtual/_tslib.cjs');
|
|
|
7
7
|
var stellarSdk = require('@stellar/stellar-sdk');
|
|
8
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
9
|
var buildPaymentTransaction = require('../utils/buildPaymentTransaction.cjs');
|
|
10
|
+
var buildTrustlineTransaction = require('../utils/buildTrustlineTransaction.cjs');
|
|
10
11
|
var checkTrustline = require('../utils/checkTrustline.cjs');
|
|
11
12
|
var createPaymentAsset = require('../utils/createPaymentAsset.cjs');
|
|
12
13
|
var getAccountBalance = require('../utils/getAccountBalance.cjs');
|
|
@@ -99,6 +100,37 @@ class StellarWallet extends walletConnectorCore.Wallet {
|
|
|
99
100
|
return response.hash;
|
|
100
101
|
});
|
|
101
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Adds a trustline for a non-native Stellar asset to the wallet.
|
|
105
|
+
*
|
|
106
|
+
* Trustlines allow an account to hold and transact with non-native assets.
|
|
107
|
+
* Each trustline reserves a small amount of XLM as a base reserve.
|
|
108
|
+
*
|
|
109
|
+
* @param assetCode - Asset code (e.g., "USDC")
|
|
110
|
+
* @param assetIssuer - Asset issuer public key
|
|
111
|
+
* @param limit - Optional maximum balance the account can hold. Defaults to max if not provided
|
|
112
|
+
* @returns Transaction hash
|
|
113
|
+
*/
|
|
114
|
+
addTrustline(_a) {
|
|
115
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ assetCode, assetIssuer, limit, }) {
|
|
116
|
+
yield this._connector.connect();
|
|
117
|
+
const horizonServer = yield this.getHorizonServer();
|
|
118
|
+
const sourceAccount = yield horizonServer.loadAccount(this.address);
|
|
119
|
+
const networkPassphrase = yield this._connector.getNetworkPassphrase();
|
|
120
|
+
const asset = createPaymentAsset.createPaymentAsset({ code: assetCode, issuer: assetIssuer });
|
|
121
|
+
const transaction = buildTrustlineTransaction.buildTrustlineTransaction({
|
|
122
|
+
asset,
|
|
123
|
+
limit,
|
|
124
|
+
networkPassphrase,
|
|
125
|
+
sourceAccount,
|
|
126
|
+
});
|
|
127
|
+
const transactionXdr = transaction.toXDR();
|
|
128
|
+
const signedXdr = yield this.signTransaction(transactionXdr);
|
|
129
|
+
const transactionToSubmit = stellarSdk.TransactionBuilder.fromXDR(signedXdr, networkPassphrase);
|
|
130
|
+
const response = yield horizonServer.submitTransaction(transactionToSubmit);
|
|
131
|
+
return response.hash;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
102
134
|
/**
|
|
103
135
|
* Signs a Stellar transaction XDR.
|
|
104
136
|
*
|
|
@@ -30,6 +30,22 @@ export declare class StellarWallet extends Wallet<StellarWalletConnector> {
|
|
|
30
30
|
* @returns Transaction hash
|
|
31
31
|
*/
|
|
32
32
|
sendBalance(params: StellarSendBalanceProps): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Adds a trustline for a non-native Stellar asset to the wallet.
|
|
35
|
+
*
|
|
36
|
+
* Trustlines allow an account to hold and transact with non-native assets.
|
|
37
|
+
* Each trustline reserves a small amount of XLM as a base reserve.
|
|
38
|
+
*
|
|
39
|
+
* @param assetCode - Asset code (e.g., "USDC")
|
|
40
|
+
* @param assetIssuer - Asset issuer public key
|
|
41
|
+
* @param limit - Optional maximum balance the account can hold. Defaults to max if not provided
|
|
42
|
+
* @returns Transaction hash
|
|
43
|
+
*/
|
|
44
|
+
addTrustline({ assetCode, assetIssuer, limit, }: {
|
|
45
|
+
assetCode: string;
|
|
46
|
+
assetIssuer: string;
|
|
47
|
+
limit?: string;
|
|
48
|
+
}): Promise<string>;
|
|
33
49
|
/**
|
|
34
50
|
* Signs a Stellar transaction XDR.
|
|
35
51
|
*
|
|
@@ -3,6 +3,7 @@ import { __awaiter } from '../../_virtual/_tslib.js';
|
|
|
3
3
|
import { TransactionBuilder } from '@stellar/stellar-sdk';
|
|
4
4
|
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { buildPaymentTransaction } from '../utils/buildPaymentTransaction.js';
|
|
6
|
+
import { buildTrustlineTransaction } from '../utils/buildTrustlineTransaction.js';
|
|
6
7
|
import { checkTrustline } from '../utils/checkTrustline.js';
|
|
7
8
|
import { createPaymentAsset } from '../utils/createPaymentAsset.js';
|
|
8
9
|
import { getAccountBalance } from '../utils/getAccountBalance.js';
|
|
@@ -95,6 +96,37 @@ class StellarWallet extends Wallet {
|
|
|
95
96
|
return response.hash;
|
|
96
97
|
});
|
|
97
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Adds a trustline for a non-native Stellar asset to the wallet.
|
|
101
|
+
*
|
|
102
|
+
* Trustlines allow an account to hold and transact with non-native assets.
|
|
103
|
+
* Each trustline reserves a small amount of XLM as a base reserve.
|
|
104
|
+
*
|
|
105
|
+
* @param assetCode - Asset code (e.g., "USDC")
|
|
106
|
+
* @param assetIssuer - Asset issuer public key
|
|
107
|
+
* @param limit - Optional maximum balance the account can hold. Defaults to max if not provided
|
|
108
|
+
* @returns Transaction hash
|
|
109
|
+
*/
|
|
110
|
+
addTrustline(_a) {
|
|
111
|
+
return __awaiter(this, arguments, void 0, function* ({ assetCode, assetIssuer, limit, }) {
|
|
112
|
+
yield this._connector.connect();
|
|
113
|
+
const horizonServer = yield this.getHorizonServer();
|
|
114
|
+
const sourceAccount = yield horizonServer.loadAccount(this.address);
|
|
115
|
+
const networkPassphrase = yield this._connector.getNetworkPassphrase();
|
|
116
|
+
const asset = createPaymentAsset({ code: assetCode, issuer: assetIssuer });
|
|
117
|
+
const transaction = buildTrustlineTransaction({
|
|
118
|
+
asset,
|
|
119
|
+
limit,
|
|
120
|
+
networkPassphrase,
|
|
121
|
+
sourceAccount,
|
|
122
|
+
});
|
|
123
|
+
const transactionXdr = transaction.toXDR();
|
|
124
|
+
const signedXdr = yield this.signTransaction(transactionXdr);
|
|
125
|
+
const transactionToSubmit = TransactionBuilder.fromXDR(signedXdr, networkPassphrase);
|
|
126
|
+
const response = yield horizonServer.submitTransaction(transactionToSubmit);
|
|
127
|
+
return response.hash;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
98
130
|
/**
|
|
99
131
|
* Signs a Stellar transaction XDR.
|
|
100
132
|
*
|