Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: give registry option between CDN and npm package #332

Merged
merged 7 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Checkout files
uses: actions/checkout@v4

- name: Install Node v16
- name: Install Node 18
uses: actions/setup-node@v4
with:
node-version: '16.13'
node-version: '18'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down Expand Up @@ -49,10 +49,10 @@ jobs:
- name: Checkout files
uses: actions/checkout@v4

- name: Install Node v16
- name: Install Node 18
uses: actions/setup-node@v4
with:
node-version: '16.13'
node-version: '18'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down Expand Up @@ -80,10 +80,10 @@ jobs:
- name: Checkout files
uses: actions/checkout@v4

- name: Install Node v16
- name: Install Node v18
uses: actions/setup-node@v4
with:
node-version: '16.13'
node-version: '18'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ Note: System refers to System Parachains like Asset Hub.

`yarn add @substrate/asset-transfer-api`

### NodeJS Version

Recommended: v21 or greater
When the API is initalized using the `CDN`, `node:fetch` is being used and is stable in node v21. Therefore it is recommended to use v21 or greater.

### Example Usage

**NOTE:** For more practical usage, and specified examples please look through our `./examples` directory to see more use cases. To
Expand Down Expand Up @@ -131,6 +136,13 @@ type AssetTransferApiOpts = {
* NOTE: It supports adding info for `polkadot`, `kusama`, and `westend`.
*/
injectedRegistry?: RequireAtLeastOne<ChainInfoRegistry>;
/**
* RegistryTypes is a string and can either be 'CDN' or 'NPM'.
*
* CDN - The registry will be initialized with the up to date version given the CDN
* NPM - The registry will be initialized with the NPM version which is updated less frequently.
*/
registryType?: RegistryTypes;
};
```

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

Large diffs are not rendered by default.

25 changes: 20 additions & 5 deletions docs/classes/AssetTransferApi.AssetTransferApi.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h4>Hierarchy</h4>
<ul class="tsd-hierarchy">
<li><span class="target">AssetTransferApi</span></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/c259cd2/src/AssetTransferApi.ts#L79">AssetTransferApi.ts:79</a></li></ul></aside>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/bf6d01c/src/AssetTransferApi.ts#L81">AssetTransferApi.ts:81</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 @@ -39,6 +39,7 @@ <h3 class="tsd-index-heading">Methods</h3>
<div class="tsd-index-list"><a href="AssetTransferApi.AssetTransferApi.html#createTransferTransaction" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-2048"><rect fill="var(--color-icon-background)" stroke="#FF4DB8" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z" fill="var(--color-text)"></path></g></svg><span>create<wbr/>Transfer<wbr/>Transaction</span></a>
<a href="AssetTransferApi.AssetTransferApi.html#decodeExtrinsic" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>decode<wbr/>Extrinsic</span></a>
<a href="AssetTransferApi.AssetTransferApi.html#fetchFeeInfo" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>fetch<wbr/>Fee<wbr/>Info</span></a>
<a href="AssetTransferApi.AssetTransferApi.html#initializeRegistry" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>initialize<wbr/>Registry</span></a>
</div></section></div></details></section></section>
<section class="tsd-panel-group tsd-member-group">
<h2>Methods</h2>
Expand Down Expand Up @@ -88,7 +89,7 @@ <h5><span class="tsd-kind-parameter">opts</span>: <a href="../interfaces/types.T
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/types.TxResult.html" class="tsd-signature-type tsd-kind-interface">TxResult</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type tsd-kind-type-parameter">T</span><span class="tsd-signature-symbol">&gt;</span><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/c259cd2/src/AssetTransferApi.ts#L126">AssetTransferApi.ts:126</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/bf6d01c/src/AssetTransferApi.ts#L136">AssetTransferApi.ts:136</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="decodeExtrinsic" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>decode<wbr/>Extrinsic</span><a href="#decodeExtrinsic" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures">
Expand Down Expand Up @@ -119,7 +120,7 @@ <h5><span class="tsd-kind-parameter">format</span>: <span class="tsd-signature-t
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</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/c259cd2/src/AssetTransferApi.ts#L525">AssetTransferApi.ts:525</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/bf6d01c/src/AssetTransferApi.ts#L456">AssetTransferApi.ts:456</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="fetchFeeInfo" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>fetch<wbr/>Fee<wbr/>Info</span><a href="#fetchFeeInfo" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures">
Expand Down Expand Up @@ -150,7 +151,20 @@ <h5><span class="tsd-kind-parameter">format</span>: <span class="tsd-signature-t
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type ">RuntimeDispatchInfo</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type ">RuntimeDispatchInfoV1</span><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/c259cd2/src/AssetTransferApi.ts#L479">AssetTransferApi.ts:479</a></li></ul></aside></li></ul></section></section></div>
<li>Defined in <a href="https://github.com/paritytech/asset-transfer-api/blob/bf6d01c/src/AssetTransferApi.ts#L410">AssetTransferApi.ts:410</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="initializeRegistry" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>initialize<wbr/>Registry</span><a href="#initializeRegistry" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures">
<li class="tsd-signature tsd-anchor-link" id="initializeRegistry.initializeRegistry-1"><span class="tsd-kind-call-signature">initialize<wbr/>Registry</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><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span><a href="#initializeRegistry.initializeRegistry-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></li>
<li class="tsd-description">
<div class="tsd-comment tsd-typography"><p>Initialize the registry. This will only activate the registry for the CDN.
If the <code>registryType</code> is <code>NPM</code> the initalization will exit since the AssetTransferApi
initializes with the reigstry from the NPM package.</p>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><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/bf6d01c/src/AssetTransferApi.ts#L384">AssetTransferApi.ts:384</a></li></ul></aside></li></ul></section></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand All @@ -170,7 +184,8 @@ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon
<ul>
<li><a href="#createTransferTransaction" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>create<wbr/>Transfer<wbr/>Transaction</span></a></li>
<li><a href="#decodeExtrinsic" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>decode<wbr/>Extrinsic</span></a></li>
<li><a href="#fetchFeeInfo" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>fetch<wbr/>Fee<wbr/>Info</span></a></li></ul></div></details></div>
<li><a href="#fetchFeeInfo" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>fetch<wbr/>Fee<wbr/>Info</span></a></li>
<li><a href="#initializeRegistry" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>initialize<wbr/>Registry</span></a></li></ul></div></details></div>
<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.4</span></a>
<ul class="tsd-small-nested-navigation">
Expand Down
Loading