@paraspell/sdk 0.0.19 → 0.0.20

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 CHANGED
@@ -43,6 +43,11 @@ pnpm install @paraspell/sdk
43
43
 
44
44
 
45
45
  ```js
46
+ /////////NEW BUILDER STYLE IMPORT///////////
47
+
48
+ import { Builder } from '@paraspell/sdk'
49
+
50
+ /////////OLD STYLE IMPORT & IMPORT FOR ASSET PALLET//////////
46
51
 
47
52
  // ESM
48
53
  import * as paraspell from '@paraspell/sdk'
@@ -60,6 +65,25 @@ const paraspell = require('@paraspell/sdk')
60
65
 
61
66
  //XCM pallet (Combined xTokens, polkadotXCM, ormlXTokens, XcmPallet & relayerXCM):
62
67
 
68
+ //////////NEW BUILDER PATTERN XCM & HRMP CONSTRUCTION//////////
69
+
70
+ //Transfer tokens from Parachain to Parachain
71
+ Builder(api).from(NODE).to(NODE).currency(CurrencyString).currencyId(currencyId).amount(amount).address(address).build()
72
+
73
+ //Transfer tokens from Relay chain to Parachain
74
+ Builder(api).to(NODE).amount(amount).address(address).build()
75
+
76
+ //Transfer tokens from Parachain to Relay chain
77
+ Builder(api).from(NODE).currency(CurrencyString).currencyId(currencyId).amount(amount).address(address).build()
78
+
79
+ //Close HRMP channels
80
+ Builder(api).from(NODE).closeChannel().inbound(inbound).outbound(outbound).build()
81
+
82
+ //Open HRMP channels
83
+ Builder(api).from(NODE).to(NODE).openChannel().maxSize(maxSize).maxMessageSize(maxMsgSize).build()
84
+
85
+ ///////////OLD STYLE XCM & HRMP CONSTRUCTION//////////////
86
+
63
87
  //Transfer tokens from Parachain to Parachain
64
88
  paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name string, currency: currency symbol string, currencyID: number (If applicable), amount: any, to: destination address string, destination: destination Parachain ID)
65
89
 
@@ -70,16 +94,14 @@ paraspell.xcmPallet.send(api: ApiPromise, origin: origin Parachain name strin
70
94
  paraspell.xcmPallet.transferRelayToPara(api: ApiPromise, destination: destination Parachain ID, amount: any, to: destination address string)
71
95
 
72
96
  //hrmp pallet:
73
-
74
97
  //Close HRMP channels
75
98
  paraspell.closeChannels.closeChannel(api: ApiPromise, origin: origin Parachain ID, inbound: number, outbound: number)
76
99
 
77
-
78
100
  //parasSudoWrapper pallet:
79
-
80
101
  //Open HRMP channels
81
102
  paraspell.openChannels.openChannel(api: ApiPromise, origin: origin Parachain ID, destination: destination Parachain ID, maxSize: number, maxMessageSize: number)
82
103
 
104
+ ////////ASSET PALLET CONSTRUCTION UNCHANGED////////
83
105
 
84
106
  //Asset pallet
85
107
 
@@ -139,8 +161,11 @@ paraspell.NODE_NAMES
139
161
 
140
162
 
141
163
  ## Founded by
164
+ [<img width="245" alt="web3 foundation_grants_badge_black" src="https://user-images.githubusercontent.com/55763425/211145923-f7ee2a57-3e63-4b7d-9674-2da9db46b2ee.png">](https://github.com/w3f/Grants-Program/pull/1245)
165
+ [<img width="245" alt="web3 foundation_grants_badge_white (1)" src="https://user-images.githubusercontent.com/55763425/211069914-bbec9e28-7a0d-417b-8149-087b7f04e57e.png">](https://github.com/w3f/Grants-Program/pull/1245)
166
+
142
167
  [![logo-v1](https://user-images.githubusercontent.com/55763425/204865221-90d2b3cd-f2ac-48a2-a367-08722aa8e923.svg)](https://bsx.fi/)
143
-
168
+
144
169
 
145
170
 
146
171
  ## License
package/dist/index.cjs CHANGED
@@ -3733,6 +3733,148 @@ const index = {
3733
3733
  closeChannel: closeChannel
3734
3734
  };
3735
3735
 
3736
+ class CloseChannelBuilder {
3737
+ constructor(api, from) {
3738
+ this.api = api;
3739
+ this.from = from;
3740
+ }
3741
+ static create(api, from) {
3742
+ return new CloseChannelBuilder(api, from);
3743
+ }
3744
+ inbound(inbound) {
3745
+ this._inbound = inbound;
3746
+ return this;
3747
+ }
3748
+ outbound(outbound) {
3749
+ this._outbound = outbound;
3750
+ return this;
3751
+ }
3752
+ build() {
3753
+ return closeChannel(this.api, this.from, this._inbound, this._outbound);
3754
+ }
3755
+ }
3756
+ const CloseChannelBuilder$1 = CloseChannelBuilder;
3757
+
3758
+ class OpenChannelBuilder {
3759
+ constructor(api, from, to) {
3760
+ this.api = api;
3761
+ this.from = from;
3762
+ this.to = to;
3763
+ }
3764
+ static create(api, from, to) {
3765
+ return new OpenChannelBuilder(api, from, to);
3766
+ }
3767
+ maxSize(size) {
3768
+ this._maxSize = size;
3769
+ return this;
3770
+ }
3771
+ maxMessageSize(size) {
3772
+ this._maxMessageSize = size;
3773
+ return this;
3774
+ }
3775
+ build() {
3776
+ return openChannel(this.api, this.from, this.to, this._maxSize, this._maxMessageSize);
3777
+ }
3778
+ }
3779
+ const OpenChannelBuilder$1 = OpenChannelBuilder;
3780
+
3781
+ class RelayToParaBuilder {
3782
+ constructor(api, to) {
3783
+ this.api = api;
3784
+ this.to = to;
3785
+ }
3786
+ static create(api, to) {
3787
+ return new RelayToParaBuilder(api, to);
3788
+ }
3789
+ amount(amount) {
3790
+ this._amount = amount;
3791
+ return this;
3792
+ }
3793
+ address(address) {
3794
+ this._address = address;
3795
+ return this;
3796
+ }
3797
+ build() {
3798
+ return transferRelayToPara(this.api, this.to, this._amount, this._address);
3799
+ }
3800
+ }
3801
+ const RelayToParaBuilder$1 = RelayToParaBuilder;
3802
+
3803
+ class SendBuilder {
3804
+ constructor(api, from, to, currency) {
3805
+ this.api = api;
3806
+ this.from = from;
3807
+ this.to = to;
3808
+ this.currency = currency;
3809
+ }
3810
+ static createParaToRelay(api, from, currency) {
3811
+ return new SendBuilder(api, from, void 0, currency);
3812
+ }
3813
+ static createParaToPara(api, from, to, currency) {
3814
+ return new SendBuilder(api, from, to, currency);
3815
+ }
3816
+ currencyId(currencyId) {
3817
+ this._currencyId = currencyId;
3818
+ return this;
3819
+ }
3820
+ amount(amount) {
3821
+ this._amount = amount;
3822
+ return this;
3823
+ }
3824
+ address(address) {
3825
+ this._address = address;
3826
+ return this;
3827
+ }
3828
+ build() {
3829
+ return send(this.api, this.from, this.currency, this._currencyId, this._amount, this._address, this.to);
3830
+ }
3831
+ }
3832
+ const SendBuilder$1 = SendBuilder;
3833
+
3834
+ class ToGeneralBuilder {
3835
+ constructor(api, from, to) {
3836
+ this.api = api;
3837
+ this.from = from;
3838
+ this.to = to;
3839
+ }
3840
+ currency(currency) {
3841
+ return SendBuilder$1.createParaToPara(this.api, this.from, this.to, currency);
3842
+ }
3843
+ openChannel() {
3844
+ return OpenChannelBuilder$1.create(this.api, this.from, this.to);
3845
+ }
3846
+ }
3847
+ class FromGeneralBuilder {
3848
+ constructor(api, from) {
3849
+ this.api = api;
3850
+ this.from = from;
3851
+ }
3852
+ to(node) {
3853
+ return new ToGeneralBuilder(this.api, this.from, node);
3854
+ }
3855
+ currency(currency) {
3856
+ return SendBuilder$1.createParaToRelay(this.api, this.from, currency);
3857
+ }
3858
+ closeChannel() {
3859
+ return CloseChannelBuilder$1.create(this.api, this.from);
3860
+ }
3861
+ }
3862
+ class GeneralBuilder {
3863
+ constructor(api) {
3864
+ this.api = api;
3865
+ }
3866
+ from(node) {
3867
+ return new FromGeneralBuilder(this.api, node);
3868
+ }
3869
+ to(node) {
3870
+ return RelayToParaBuilder$1.create(this.api, node);
3871
+ }
3872
+ }
3873
+ function Builder(api) {
3874
+ return new GeneralBuilder(api);
3875
+ }
3876
+
3877
+ exports.Builder = Builder;
3736
3878
  exports.NODE_NAMES = NODE_NAMES;
3737
3879
  exports.assets = index$3;
3738
3880
  exports.closeChannels = index;
package/dist/index.d.ts CHANGED
@@ -91,4 +91,71 @@ declare namespace index {
91
91
  };
92
92
  }
93
93
 
94
- export { Extrinsic, ExtrinsicFunction, NODE_NAMES, TAssetDetails, TAssetJsonMap, TNativeAssetDetails, TNode, TNodeAssets, TNodeDetails, TPalletType, TRelayChainType, TScenario, UpdateFunction, index as assets, index$1 as closeChannels, index$2 as openChannels, index$3 as xcmPallet };
94
+ interface FinalRelayToParaBuilder$1 {
95
+ build(): Extrinsic | never;
96
+ }
97
+ interface AddressRelayToParaBuilder {
98
+ address(address: string): FinalRelayToParaBuilder$1;
99
+ }
100
+ interface AmountRelayToParaBuilder {
101
+ amount(amount: number): AddressRelayToParaBuilder;
102
+ }
103
+
104
+ interface FinalCloseChannelBuilder {
105
+ build(): Extrinsic;
106
+ }
107
+ interface OutboundCloseChannelBuilder {
108
+ outbound(inbound: number): FinalCloseChannelBuilder;
109
+ }
110
+ interface InboundCloseChannelBuilder {
111
+ inbound(inbound: number): OutboundCloseChannelBuilder;
112
+ }
113
+
114
+ interface FinalOpenChannelBuilder {
115
+ build(): Extrinsic;
116
+ }
117
+ interface MaxMessageSizeOpenChannelBuilder {
118
+ maxMessageSize(size: number): FinalOpenChannelBuilder;
119
+ }
120
+ interface MaxSizeOpenChannelBuilder {
121
+ maxSize(size: number): MaxMessageSizeOpenChannelBuilder;
122
+ }
123
+
124
+ interface FinalRelayToParaBuilder {
125
+ build(): Extrinsic | never;
126
+ }
127
+ interface AddressSendBuilder {
128
+ address(address: string): FinalRelayToParaBuilder;
129
+ }
130
+ interface AmountSendBuilder {
131
+ amount(amount: any): AddressSendBuilder;
132
+ }
133
+ interface CurrencyIdSendBuilder {
134
+ currencyId(currencyId: number): AmountSendBuilder;
135
+ }
136
+
137
+ declare class ToGeneralBuilder {
138
+ private api;
139
+ private from;
140
+ private to;
141
+ constructor(api: ApiPromise, from: TNode, to: TNode);
142
+ currency(currency: string): CurrencyIdSendBuilder;
143
+ openChannel(): MaxSizeOpenChannelBuilder;
144
+ }
145
+ declare class FromGeneralBuilder {
146
+ private api;
147
+ private from;
148
+ constructor(api: ApiPromise, from: TNode);
149
+ to(node: TNode): ToGeneralBuilder;
150
+ currency(currency: string): CurrencyIdSendBuilder;
151
+ closeChannel(): InboundCloseChannelBuilder;
152
+ }
153
+ declare class GeneralBuilder {
154
+ private api;
155
+ constructor(api: ApiPromise);
156
+ from(node: TNode): FromGeneralBuilder;
157
+ to(node: TNode): AmountRelayToParaBuilder;
158
+ }
159
+ declare function Builder(api: ApiPromise): GeneralBuilder;
160
+
161
+ export { Builder, Extrinsic, ExtrinsicFunction, NODE_NAMES, TAssetDetails, TAssetJsonMap, TNativeAssetDetails, TNode, TNodeAssets, TNodeDetails, TPalletType, TRelayChainType, TScenario, UpdateFunction, index as assets, index$1 as closeChannels, index$2 as openChannels, index$3 as xcmPallet };
package/dist/index.mjs CHANGED
@@ -3731,4 +3731,145 @@ const index = {
3731
3731
  closeChannel: closeChannel
3732
3732
  };
3733
3733
 
3734
- export { NODE_NAMES, index$3 as assets, index as closeChannels, index$1 as openChannels, index$2 as xcmPallet };
3734
+ class CloseChannelBuilder {
3735
+ constructor(api, from) {
3736
+ this.api = api;
3737
+ this.from = from;
3738
+ }
3739
+ static create(api, from) {
3740
+ return new CloseChannelBuilder(api, from);
3741
+ }
3742
+ inbound(inbound) {
3743
+ this._inbound = inbound;
3744
+ return this;
3745
+ }
3746
+ outbound(outbound) {
3747
+ this._outbound = outbound;
3748
+ return this;
3749
+ }
3750
+ build() {
3751
+ return closeChannel(this.api, this.from, this._inbound, this._outbound);
3752
+ }
3753
+ }
3754
+ const CloseChannelBuilder$1 = CloseChannelBuilder;
3755
+
3756
+ class OpenChannelBuilder {
3757
+ constructor(api, from, to) {
3758
+ this.api = api;
3759
+ this.from = from;
3760
+ this.to = to;
3761
+ }
3762
+ static create(api, from, to) {
3763
+ return new OpenChannelBuilder(api, from, to);
3764
+ }
3765
+ maxSize(size) {
3766
+ this._maxSize = size;
3767
+ return this;
3768
+ }
3769
+ maxMessageSize(size) {
3770
+ this._maxMessageSize = size;
3771
+ return this;
3772
+ }
3773
+ build() {
3774
+ return openChannel(this.api, this.from, this.to, this._maxSize, this._maxMessageSize);
3775
+ }
3776
+ }
3777
+ const OpenChannelBuilder$1 = OpenChannelBuilder;
3778
+
3779
+ class RelayToParaBuilder {
3780
+ constructor(api, to) {
3781
+ this.api = api;
3782
+ this.to = to;
3783
+ }
3784
+ static create(api, to) {
3785
+ return new RelayToParaBuilder(api, to);
3786
+ }
3787
+ amount(amount) {
3788
+ this._amount = amount;
3789
+ return this;
3790
+ }
3791
+ address(address) {
3792
+ this._address = address;
3793
+ return this;
3794
+ }
3795
+ build() {
3796
+ return transferRelayToPara(this.api, this.to, this._amount, this._address);
3797
+ }
3798
+ }
3799
+ const RelayToParaBuilder$1 = RelayToParaBuilder;
3800
+
3801
+ class SendBuilder {
3802
+ constructor(api, from, to, currency) {
3803
+ this.api = api;
3804
+ this.from = from;
3805
+ this.to = to;
3806
+ this.currency = currency;
3807
+ }
3808
+ static createParaToRelay(api, from, currency) {
3809
+ return new SendBuilder(api, from, void 0, currency);
3810
+ }
3811
+ static createParaToPara(api, from, to, currency) {
3812
+ return new SendBuilder(api, from, to, currency);
3813
+ }
3814
+ currencyId(currencyId) {
3815
+ this._currencyId = currencyId;
3816
+ return this;
3817
+ }
3818
+ amount(amount) {
3819
+ this._amount = amount;
3820
+ return this;
3821
+ }
3822
+ address(address) {
3823
+ this._address = address;
3824
+ return this;
3825
+ }
3826
+ build() {
3827
+ return send(this.api, this.from, this.currency, this._currencyId, this._amount, this._address, this.to);
3828
+ }
3829
+ }
3830
+ const SendBuilder$1 = SendBuilder;
3831
+
3832
+ class ToGeneralBuilder {
3833
+ constructor(api, from, to) {
3834
+ this.api = api;
3835
+ this.from = from;
3836
+ this.to = to;
3837
+ }
3838
+ currency(currency) {
3839
+ return SendBuilder$1.createParaToPara(this.api, this.from, this.to, currency);
3840
+ }
3841
+ openChannel() {
3842
+ return OpenChannelBuilder$1.create(this.api, this.from, this.to);
3843
+ }
3844
+ }
3845
+ class FromGeneralBuilder {
3846
+ constructor(api, from) {
3847
+ this.api = api;
3848
+ this.from = from;
3849
+ }
3850
+ to(node) {
3851
+ return new ToGeneralBuilder(this.api, this.from, node);
3852
+ }
3853
+ currency(currency) {
3854
+ return SendBuilder$1.createParaToRelay(this.api, this.from, currency);
3855
+ }
3856
+ closeChannel() {
3857
+ return CloseChannelBuilder$1.create(this.api, this.from);
3858
+ }
3859
+ }
3860
+ class GeneralBuilder {
3861
+ constructor(api) {
3862
+ this.api = api;
3863
+ }
3864
+ from(node) {
3865
+ return new FromGeneralBuilder(this.api, node);
3866
+ }
3867
+ to(node) {
3868
+ return RelayToParaBuilder$1.create(this.api, node);
3869
+ }
3870
+ }
3871
+ function Builder(api) {
3872
+ return new GeneralBuilder(api);
3873
+ }
3874
+
3875
+ export { Builder, NODE_NAMES, index$3 as assets, index as closeChannels, index$1 as openChannels, index$2 as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",