-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix token symbol testnet #2159
Merged
Merged
Fix token symbol testnet #2159
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6e26626
Use the correct symbols for each network's metadata
wilwade 941a876
Update packages for js and add (skipped) test for testing transaction…
wilwade 81ae3af
Stop reporting on deprecated rpcs
wilwade 746e219
Bump spec version
wilwade ddbeb79
Update cargo deny exclusions
wilwade a583a2e
Fix api-augment type build
wilwade 7e1f84a
Fix copy paste error
wilwade File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Large diffs are not rendered by default.
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
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,58 @@ | ||
import '@frequency-chain/api-augment'; | ||
|
||
import assert from 'assert'; | ||
|
||
import { KeyringPair } from '@polkadot/keyring/types'; | ||
import { merkleizeMetadata } from '@polkadot-api/merkleize-metadata'; | ||
import { Extrinsic, ExtrinsicHelper } from '../scaffolding/extrinsicHelpers'; | ||
import { | ||
createKeys, | ||
createAndFundKeypair, | ||
assertExtrinsicSuccess, | ||
generateSchemaPartialName, | ||
} from '../scaffolding/helpers'; | ||
import { getFundingSource } from '../scaffolding/funding'; | ||
import { u8aToHex } from '@polkadot/util'; | ||
|
||
const fundingSource = getFundingSource('check-metadata-hash'); | ||
|
||
// This is skipped as it requires the e2e tests to be run | ||
// against a Frequency build that has the metadata-hash feature | ||
// enabled. That feature is a large increase in compile time however. | ||
describe.skip('Check Metadata Hash', function () { | ||
let keys: KeyringPair; | ||
let accountWithNoFunds: KeyringPair; | ||
|
||
before(async function () { | ||
keys = await createAndFundKeypair(fundingSource, 10_000_000n); | ||
accountWithNoFunds = createKeys(); | ||
}); | ||
|
||
it('should successfully transfer funds', async function () { | ||
const tx = ExtrinsicHelper.api.tx.balances.transferKeepAlive(accountWithNoFunds.address, 5_000_000n); | ||
|
||
const api = ExtrinsicHelper.apiPromise; | ||
const metadata = await api.call.metadata.metadataAtVersion(15); | ||
const { specName, specVersion } = api.runtimeVersion; | ||
const merkleInfo = { | ||
base58Prefix: api.consts.system.ss58Prefix.toNumber(), | ||
decimals: api.registry.chainDecimals[0], | ||
specName: specName.toString(), | ||
specVersion: specVersion.toNumber(), | ||
tokenSymbol: api.registry.chainTokens[0], | ||
}; | ||
|
||
const merkleizedMetadata = merkleizeMetadata(metadata.toHex(), merkleInfo); | ||
const metadataHash = u8aToHex(merkleizedMetadata.digest()); | ||
|
||
const extrinsic = new Extrinsic(() => tx, keys); | ||
|
||
const { eventMap } = await extrinsic.signAndSend('auto', { | ||
withSignedTransaction: true, | ||
mode: 1, | ||
metadataHash, | ||
}); | ||
|
||
assertExtrinsicSuccess(eventMap); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types'; | ||
import { DefinitionRpc } from '@polkadot/types/types'; | ||
import './interfaces/types-lookup.js'; | ||
import './interfaces/augment-api.js'; | ||
import './interfaces/augment-types.js'; | ||
import './interfaces/index.js'; | ||
import * as definitions from './interfaces/definitions.js'; | ||
import { v1SubstrateRpcs } from './substrate_v1_rpcs.js'; | ||
|
||
/** | ||
* Build up the types for ApiPromise.create | ||
|
@@ -18,12 +20,16 @@ export const types = Object.entries(definitions).reduce((acc, [_key, value]) => | |
/** | ||
* Build up the rpc calls for ApiPromise.create | ||
*/ | ||
export const rpc = Object.entries(definitions).reduce((acc, [key, value]) => { | ||
return { | ||
...acc, | ||
[key]: value.rpc, | ||
}; | ||
}, {}); | ||
export const rpc: Record<string, Record<string, DefinitionRpc>> = Object.entries(definitions).reduce( | ||
(acc, [key, value]) => { | ||
return { | ||
...acc, | ||
[key]: value.rpc, | ||
}; | ||
}, | ||
// v1 rpc calls to be ignored | ||
{ ...v1SubstrateRpcs } | ||
); | ||
|
||
/** | ||
* Frequency Specific Signed Extensions | ||
|
@@ -38,6 +44,14 @@ export const signedExtensions: ExtDef = { | |
extrinsic: {}, | ||
payload: {}, | ||
}, | ||
StaleHashCheckExtension: { | ||
extrinsic: {}, | ||
payload: {}, | ||
}, | ||
StorageWeightReclaim: { | ||
extrinsic: {}, | ||
payload: {}, | ||
}, | ||
Comment on lines
+47
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are the additional signed extensions, but they don't need anything extra. This removes the warning. |
||
}; | ||
|
||
/** | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allowing the pass-through of additional options such as in this case the metadata hash