-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fee payment in non native assets (#77)
* Fee payment in non native assets * fix * modify signed extra * e2e native fee payment check * fix * non-native transfer * asset-rate * fix * .. * use nightly-2024-02-03 * fixes * add missing asset rate setup * fix * fix tests * fix dependency check * test fix * last touches
- Loading branch information
Showing
20 changed files
with
268 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,8 @@ bin/ | |
.DS_Store | ||
.idea | ||
.vscode | ||
|
||
bin/ | ||
|
||
node_modules | ||
**/package-lock.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
async function submitExtrinsic(signer, call, options) { | ||
return new Promise(async (resolve, reject) => { | ||
const unsub = await call.signAndSend(signer, options, (result) => { | ||
console.log(`Current status is ${result.status}`); | ||
if (result.status.isInBlock) { | ||
console.log( | ||
`Transaction included at blockHash ${result.status.asInBlock}` | ||
); | ||
} else if (result.status.isFinalized) { | ||
console.log( | ||
`Transaction finalized at blockHash ${result.status.asFinalized}` | ||
); | ||
unsub(); | ||
return resolve(); | ||
} else if (result.isError) { | ||
console.log(`Transaction error`); | ||
unsub(); | ||
return resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = { submitExtrinsic } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { ApiPromise, WsProvider } = require("@polkadot/api"); | ||
const { submitExtrinsic } = require("./common"); | ||
|
||
const ASSET_ID = 42; | ||
|
||
async function run(nodeName, networkInfo, _jsArgs) { | ||
const { wsUri } = networkInfo.nodesByName[nodeName]; | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider(wsUri), | ||
signedExtensions: { | ||
ChargeAssetTxPayment: { | ||
extrinsic: { | ||
tip: "Compact<Balance>", | ||
assetId: "Option<AssetId>", | ||
}, | ||
payload: {}, | ||
}, | ||
}, | ||
}); | ||
|
||
// account to submit tx | ||
const keyring = new zombie.Keyring({ type: "sr25519" }); | ||
const alice = keyring.addFromUri("//Alice"); | ||
|
||
const assetMetadata = { | ||
decimals: 10, | ||
name: "DOT", | ||
symbol: "DOT", | ||
existentialDeposit: 10n**3n, | ||
location: null, | ||
additional: null | ||
}; | ||
|
||
const assetSetupCalls = [ | ||
api.tx.assetRegistry.registerAsset(assetMetadata, ASSET_ID), | ||
api.tx.assetRate.create(ASSET_ID, 1000000000000000000n), // 1 on 1 | ||
api.tx.tokens.setBalance(alice.address, ASSET_ID, 10n**12n, 0), | ||
]; | ||
const batchCall = api.tx.utility.batch(assetSetupCalls); | ||
const sudo = api.tx.sudo.sudo(batchCall); | ||
|
||
await submitExtrinsic(alice, sudo, {}); | ||
|
||
const remarkCall = api.tx.system.remark("0x44"); | ||
await submitExtrinsic(alice, remarkCall, {assetId: ASSET_ID}); | ||
} | ||
|
||
module.exports = { run }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { ApiPromise, WsProvider } = require("@polkadot/api"); | ||
const { submitExtrinsic } = require("./common"); | ||
|
||
async function run(nodeName, networkInfo, _jsArgs) { | ||
const { wsUri } = networkInfo.nodesByName[nodeName]; | ||
const api = await ApiPromise.create({provider: new WsProvider(wsUri)}); | ||
|
||
// account to submit tx | ||
const keyring = new zombie.Keyring({ type: "sr25519" }); | ||
const alice = keyring.addFromUri("//Alice"); | ||
const bob = keyring.addFromUri("//Bob"); | ||
|
||
const call = api.tx.balances.transferKeepAlive(bob.address, 10n**6n); | ||
const sudo = api.tx.sudo.sudo(call); | ||
await submitExtrinsic(alice, sudo, {}); | ||
} | ||
|
||
module.exports = { run }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "test", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@polkadot/api": "^11.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.