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

Fix token symbol testnet #2159

Merged
merged 7 commits into from
Sep 23, 2024
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
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ ignore = [
{ id = "RUSTSEC-2024-0336", reason = "Only use of rustls@v0.20.9 is in futures-rustls which does not use the effected code" },
{ id = "RUSTSEC-2024-0344", reason = "We are only able to remove this once parity updates its dependencies. Older versions of curve25519-dalek should get replaces with >= 4.1.3" },
{ id = "RUSTSEC-2022-0093", reason = "The vulnerable code is not exploitable in Frequency because the signing function is not exposed in a way that allows the use of arbitrary public keys, ensuring protection against the described vulnerability." },
{ id = "RUSTSEC-2024-0370", reason = "proc-macro-error is used by a few dependencies, and while unmaintained, is not currently an issue." },
]
# If this is true, then cargo deny will use the git executable to fetch advisory database.
# If this is false, then it uses a built-in git library.
Expand Down
274 changes: 150 additions & 124 deletions e2e/package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
"@frequency-chain/api-augment": "file:../js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz",
"@helia/unixfs": "^3.0.7",
"@noble/curves": "^1.6.0",
"@polkadot/api": "13.0.1",
"@polkadot/types": "13.0.1",
"@polkadot-api/merkleize-metadata": "^1.1.2",
"@polkadot/api": "13.1.1",
"@polkadot/types": "13.1.1",
"@polkadot/util": "13.1.1",
"helia": "^4.2.6",
"multiformats": "^13.3.0",
Expand All @@ -37,7 +38,7 @@
"eslint-plugin-mocha": "^10.5.0",
"globals": "^15.9.0",
"mocha": "^10.7.3",
"node-datachannel": "^0.11.0",
"node-datachannel": "^0.12.0",
"prettier": "^3.3.3",
"sinon": "^19.0.2",
"tsx": "^4.19.1",
Expand Down
6 changes: 3 additions & 3 deletions e2e/scaffolding/extrinsicHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@frequency-chain/api-augment';
import { ApiPromise, ApiRx } from '@polkadot/api';
import { ApiTypes, AugmentedEvent, SubmittableExtrinsic } from '@polkadot/api/types';
import { ApiTypes, AugmentedEvent, SubmittableExtrinsic, SignerOptions } from '@polkadot/api/types';
import { KeyringPair } from '@polkadot/keyring/types';
import { Compact, u128, u16, u32, u64, Vec, Option, Bool } from '@polkadot/types';
import { FrameSystemAccountInfo, PalletPasskeyPasskeyPayload, SpRuntimeDispatchError } from '@polkadot/types/lookup';
Expand Down Expand Up @@ -175,14 +175,14 @@ export class Extrinsic<N = unknown, T extends ISubmittableResult = ISubmittableR
}

// This uses automatic nonce management by default.
public async signAndSend(inputNonce?: AutoNonce) {
public async signAndSend(inputNonce?: AutoNonce, options: Partial<SignerOptions> = {}) {
Copy link
Collaborator Author

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

const nonce = await autoNonce.auto(this.keys, inputNonce);

try {
const op = this.extrinsic();
// Era is 0 for tests due to issues with BirthBlock
return await firstValueFrom(
op.signAndSend(this.keys, { nonce, era: 0 }).pipe(
op.signAndSend(this.keys, { nonce, era: 0, ...options }).pipe(
tap((result) => {
// If we learn a transaction has an error status (this does NOT include RPC errors)
// Then throw an error
Expand Down
3 changes: 2 additions & 1 deletion e2e/scaffolding/funding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ export const fundingSources = [
'capacity-staking',
'capacity-transactions',
'capacity-unstaking',
'check-metadata-hash',
'frequency-misc',
'handles',
'load-signature-registry',
'messages-add-ipfs',
'misc-util-batch',
'msa-create-msa',
'msa-key-management',
'passkey-proxy',
'proxy-pallet',
'scenarios-grant-delegation',
'schemas-create',
Expand All @@ -29,7 +31,6 @@ export const fundingSources = [
'stateful-storage-handle-sig-req',
'sudo-transactions',
'time-release',
'passkey-proxy',
] as const;

// Get the correct key for this Funding Source
Expand Down
58 changes: 58 additions & 0 deletions e2e/signed-extensions/checkMetadataHash.test.ts
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 () {

Check warning on line 22 in e2e/signed-extensions/checkMetadataHash.test.ts

View workflow job for this annotation

GitHub Actions / Run E2E Tests

Unexpected skipped mocha test
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);
});
});
26 changes: 20 additions & 6 deletions js/api-augment/index.ts
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
Expand All @@ -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
Expand All @@ -38,6 +44,14 @@ export const signedExtensions: ExtDef = {
extrinsic: {},
payload: {},
},
StaleHashCheckExtension: {
extrinsic: {},
payload: {},
},
StorageWeightReclaim: {
extrinsic: {},
payload: {},
},
Comment on lines +47 to +54
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

};

/**
Expand Down
Loading
Loading