Skip to content

Commit

Permalink
fix!: replace AssetsTransferApi with AssetTransferApi (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul authored Sep 18, 2023
1 parent 5a69541 commit c32fe0a
Show file tree
Hide file tree
Showing 46 changed files with 187 additions and 187 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ Note: System refers to System Parachains like Asset Hub.
run these examples: `yarn build:examples && node ./examples/build/examples/<file_to_run>.js`.

```typescript
import { AssetsTransferApi, constructApiPromise } from '@substrate/asset-transfer-api';
import { AssetTransferApi, constructApiPromise } from '@substrate/asset-transfer-api';

// NOTE: This should all be wrapped in an asynchronous layer.

// This constructs a polkadot-js ApiPromise, it is totally viable for one to construct their
// own ApiPromise, and pass it into AssetsTransferApi, but keep in mind the `specName`, and `safeXcmVersion` are also necessary.
// own ApiPromise, and pass it into AssetTransferApi, but keep in mind the `specName`, and `safeXcmVersion` are also necessary.
const { api, specName, safeXcmVersion } = await constructApiPromise('wss://westmint-rpc.polkadot.io');

const assetsApi = new AssetsTransferApi(api, specName, safeXcmVersion);
const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);

const call = assetsApi.createTransferTransaction(
'2001', // destChainId (If the destination is a relay chain put `0`)
Expand All @@ -86,10 +86,10 @@ const call = assetsApi.createTransferTransaction(
)
```

### AssetTransferApi & AssetsTransferApiOpts & TransferArgsOpts
### AssetTransferApi & AssetTransferApiOpts & TransferArgsOpts

```Typescript
// The AssetsTransferApi exposes one method as of now called: `createTransferTransaction`
// The AssetTransferApi exposes one method as of now called: `createTransferTransaction`

/**
* Create an XCM transaction to transfer Assets, or native tokens from one
Expand All @@ -101,7 +101,7 @@ const call = assetsApi.createTransferTransaction(
* @param amounts Array of the amounts of each token to transfer
* @param opts Options
*/
AssetsTransferApi.createTransferTransaction(
AssetTransferApi.createTransferTransaction(
destChainId: string,
destAddr: string,
assetIds: string[],
Expand All @@ -112,9 +112,9 @@ AssetsTransferApi.createTransferTransaction(


```typescript
// AssetsTransferApiOpts are the options for the `AssetsTransferApi`
// AssetTransferApiOpts are the options for the `AssetTransferApi`

type AssetsTransferApiOpts = {
type AssetTransferApiOpts = {
/**
* The injectedRegistry allows you to add custom values to the predefined initialized registry.
* If you would like to see the registry you may visit https://github.com/paritytech/asset-transfer-api-registry/blob/main/registry.json
Expand Down Expand Up @@ -188,7 +188,7 @@ interface TransferArgsOpts<T extends Format> {

### Teleport and Reserve Transfer via polkadotXcm pallet

The `AssetsTransferApi.createTransferTransaction` is able to infer what kind of transaction is necessary given the inputs. When sending cross chain transfers the api does a lot of validation to ensure the inputs are valid, and the assets either exist or dont. This process is done through a registry which is maintained in a seperate repo [here](https://github.com/paritytech/asset-transfer-api-registry). If the asset in not in the registry it will then lookup if that asset exists on chain and cache it if necessary. On chain verification is not always possible in respect to the direction the asset is being sent and what the destination chain is since we only maintain one api connection. Therefore, if you would like the inject information into the registry, you can using the `injectedRegistry` option for the `AssetsTransferApi`.
The `AssetTransferApi.createTransferTransaction` is able to infer what kind of transaction is necessary given the inputs. When sending cross chain transfers the api does a lot of validation to ensure the inputs are valid, and the assets either exist or dont. This process is done through a registry which is maintained in a seperate repo [here](https://github.com/paritytech/asset-transfer-api-registry). If the asset in not in the registry it will then lookup if that asset exists on chain and cache it if necessary. On chain verification is not always possible in respect to the direction the asset is being sent and what the destination chain is since we only maintain one api connection. Therefore, if you would like the inject information into the registry, you can using the `injectedRegistry` option for the `AssetTransferApi`.

### Transferring assets via xTokens pallet

Expand Down
2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions docs/enums/errors_BaseError.BaseErrorsEnum.html

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/enums/types.Direction.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1>Enumeration Direction</h1></div>
</div>
<div class="tsd-comment tsd-typography"></div></section><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/types.ts#L25">types.ts:25</a></li></ul></aside>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/types.ts#L25">types.ts:25</a></li></ul></aside>
<section class="tsd-panel-group tsd-index-group">
<section class="tsd-panel tsd-index-panel">
<details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
Expand All @@ -47,63 +47,63 @@ <h3 class="tsd-anchor-link"><span>Para<wbr/>To<wbr/>Para</span><a href="#ParaToP
</div>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/types.ts#L41">types.ts:41</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/types.ts#L41">types.ts:41</a></li></ul></aside></section>
<section class="tsd-panel tsd-member"><a id="ParaToRelay" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>Para<wbr/>To<wbr/>Relay</span><a href="#ParaToRelay" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-enum-member">Para<wbr/>To<wbr/>Relay</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;ParaToRelay&quot;</span></div>
<div class="tsd-comment tsd-typography"><p>Parachain to Relay chain.</p>
</div>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/types.ts#L45">types.ts:45</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/types.ts#L45">types.ts:45</a></li></ul></aside></section>
<section class="tsd-panel tsd-member"><a id="ParaToSystem" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>Para<wbr/>To<wbr/>System</span><a href="#ParaToSystem" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-enum-member">Para<wbr/>To<wbr/>System</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;ParaToSystem&quot;</span></div>
<div class="tsd-comment tsd-typography"><p>Parachain to System parachain.</p>
</div>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/types.ts#L49">types.ts:49</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/types.ts#L49">types.ts:49</a></li></ul></aside></section>
<section class="tsd-panel tsd-member"><a id="RelayToPara" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>Relay<wbr/>To<wbr/>Para</span><a href="#RelayToPara" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-enum-member">Relay<wbr/>To<wbr/>Para</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;RelayToPara&quot;</span></div>
<div class="tsd-comment tsd-typography"><p>Relay chain to Parachain.</p>
</div>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/types.ts#L57">types.ts:57</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/types.ts#L57">types.ts:57</a></li></ul></aside></section>
<section class="tsd-panel tsd-member"><a id="RelayToSystem" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>Relay<wbr/>To<wbr/>System</span><a href="#RelayToSystem" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-enum-member">Relay<wbr/>To<wbr/>System</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;RelayToSystem&quot;</span></div>
<div class="tsd-comment tsd-typography"><p>Relay to System Parachain.</p>
</div>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/types.ts#L53">types.ts:53</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/types.ts#L53">types.ts:53</a></li></ul></aside></section>
<section class="tsd-panel tsd-member"><a id="SystemToPara" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>System<wbr/>To<wbr/>Para</span><a href="#SystemToPara" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-enum-member">System<wbr/>To<wbr/>Para</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;SystemToPara&quot;</span></div>
<div class="tsd-comment tsd-typography"><p>System parachain to Parachain.</p>
</div>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/types.ts#L29">types.ts:29</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/types.ts#L29">types.ts:29</a></li></ul></aside></section>
<section class="tsd-panel tsd-member"><a id="SystemToRelay" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>System<wbr/>To<wbr/>Relay</span><a href="#SystemToRelay" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-enum-member">System<wbr/>To<wbr/>Relay</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;SystemToRelay&quot;</span></div>
<div class="tsd-comment tsd-typography"><p>System parachain to Relay chain.</p>
</div>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/types.ts#L33">types.ts:33</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/types.ts#L33">types.ts:33</a></li></ul></aside></section>
<section class="tsd-panel tsd-member"><a id="SystemToSystem" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>System<wbr/>To<wbr/>System</span><a href="#SystemToSystem" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-enum-member">System<wbr/>To<wbr/>System</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;SystemToSystem&quot;</span></div>
<div class="tsd-comment tsd-typography"><p>System parachain to System parachain chain.</p>
</div>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/types.ts#L37">types.ts:37</a></li></ul></aside></section></section></div>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/types.ts#L37">types.ts:37</a></li></ul></aside></section></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down Expand Up @@ -132,7 +132,7 @@ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon
<div class="site-menu">
<nav class="tsd-navigation"><a href="../index.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g></svg><span>@substrate/asset-<wbr/>transfer-<wbr/>api -<wbr/> v0.1.0-<wbr/>beta.5</span></a>
<ul class="tsd-small-nested-navigation">
<li><a href="../modules/AssetsTransferApi.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4"></use></svg><span>Assets<wbr/>Transfer<wbr/>Api</span></a></li>
<li><a href="../modules/AssetTransferApi.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4"></use></svg><span>Asset<wbr/>Transfer<wbr/>Api</span></a></li>
<li><a href="../modules/constructApiPromise.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4"></use></svg><span>construct<wbr/>Api<wbr/>Promise</span></a></li>
<li><a href="../modules/errors_BaseError.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4"></use></svg><span>errors/<wbr/>Base<wbr/>Error</span></a></li>
<li>
Expand Down
6 changes: 3 additions & 3 deletions docs/functions/constructApiPromise.constructApiPromise.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1>Function constructApiPromise</h1></div>
<ul class="tsd-signatures">
<li class="tsd-signature tsd-anchor-link" id="constructApiPromise"><span class="tsd-kind-call-signature">construct<wbr/>Api<wbr/>Promise</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">wsUrl</span>, <span class="tsd-kind-parameter">opts</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/constructApiPromise.ApiInfo.html" class="tsd-signature-type tsd-kind-interface">ApiInfo</a><span class="tsd-signature-symbol">&gt;</span><a href="#constructApiPromise" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><g stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" id="icon-anchor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></g></svg></a></li>
<li class="tsd-description">
<div class="tsd-comment tsd-typography"><p>Construct an Polkadot-js ApiPromise, and and retrieve the specName of the chain.</p>
<div class="tsd-comment tsd-typography"><p>Construct a Polkadot-js ApiPromise, and retrieve the specName of the chain.</p>
<pre><code class="language-ts"><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">constructApiPromise</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@substrate/asset-transfer-api&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-5">const</span><span class="hl-1"> { </span><span class="hl-6">api</span><span class="hl-1">, </span><span class="hl-6">specName</span><span class="hl-1">, </span><span class="hl-6">safeXcmVersion</span><span class="hl-1"> } = </span><span class="hl-7">constructApiPromise</span><span class="hl-1">(</span><span class="hl-3">&#39;wss://some_ws_url&#39;</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
</div>
Expand All @@ -40,7 +40,7 @@ <h5><span class="tsd-kind-parameter">opts</span>: <span class="tsd-signature-typ
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/constructApiPromise.ApiInfo.html" class="tsd-signature-type tsd-kind-interface">ApiInfo</a><span class="tsd-signature-symbol">&gt;</span></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/b031f56/src/constructApiPromise.ts#L39">constructApiPromise.ts:39</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/5a69541/src/constructApiPromise.ts#L39">constructApiPromise.ts:39</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand All @@ -57,7 +57,7 @@ <h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</op
<div class="site-menu">
<nav class="tsd-navigation"><a href="../index.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g></svg><span>@substrate/asset-<wbr/>transfer-<wbr/>api -<wbr/> v0.1.0-<wbr/>beta.5</span></a>
<ul class="tsd-small-nested-navigation">
<li><a href="../modules/AssetsTransferApi.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4"></use></svg><span>Assets<wbr/>Transfer<wbr/>Api</span></a></li>
<li><a href="../modules/AssetTransferApi.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4"></use></svg><span>Asset<wbr/>Transfer<wbr/>Api</span></a></li>
<li>
<details class="tsd-index-accordion" open data-key="constructApiPromise"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon-chevronDown"></use></svg><a href="../modules/constructApiPromise.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4"></use></svg><span>construct<wbr/>Api<wbr/>Promise</span></a></summary>
<div class="tsd-accordion-details">
Expand Down
Loading

0 comments on commit c32fe0a

Please sign in to comment.