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

Signer bug fix #129

Merged
merged 9 commits into from
May 24, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Removed

### Fixed
- [\#129](https://github.com/Manta-Network/sdk/pull/129) Signer bug fix.

### Security
8 changes: 4 additions & 4 deletions manta-js/examples/balance-issue-example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default function App() {
break;
}
retryTimes += 1;
if (retryTimes >= 10) {
if (retryTimes >= 30) {
throw new Error('Check balance timeout');
}
}
Expand All @@ -129,7 +129,7 @@ export default function App() {
);
assert(transaction && transaction.txs.length > 0, 'ToPrivate Failed');
for (let i = 0; i < transaction.txs.length; i += 1) {
await transaction.txs[i].signAndSend(pair!);
await transaction.txs[i].signAndSend(pair!, { nonce: -1 });
}
await queryTransferResult(privateWallet, initialPrivateBalance);
},
Expand All @@ -152,7 +152,7 @@ export default function App() {
'PrivateTransfer Failed',
);
for (let i = 0; i < transaction.txs.length; i += 1) {
await transaction.txs[i].signAndSend(pair!);
await transaction.txs[i].signAndSend(pair!, { nonce: -1 });
}
await queryTransferResult(privateWallet, initialPrivateBalance);
},
Expand All @@ -174,7 +174,7 @@ export default function App() {
);
assert(transaction && transaction.txs.length > 0, 'ToPublic Failed');
for (let i = 0; i < transaction.txs.length; i += 1) {
await transaction.txs[i].signAndSend(pair!);
await transaction.txs[i].signAndSend(pair!, { nonce: -1 });
}
await queryTransferResult(privateWallet, initialPrivateBalance);
},
Expand Down
4 changes: 3 additions & 1 deletion manta-js/examples/extension-example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ export default function App() {
setResult('Sign Successful');
for (let i = 0; i < response.length; i++) {
const tx = api?.tx(response[i]);
const extrinsicHash = await tx?.signAndSend(publicAddress);
const extrinsicHash = await tx?.signAndSend(publicAddress, {
nonce: -1,
});
if (
typeof injected?.privateWallet.matchPrivateTransaction ===
'function'
Expand Down
30 changes: 21 additions & 9 deletions manta-js/examples/sdk-example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ import {
del as delIdbData,
} from 'idb-keyval';

const apiEndpoint = [
'https://calamari.systems/rpc',
];
// 'wss://c1.calamari.seabird.systems';
const apiEndpoint = ['https://calamari.systems/rpc'];
// 'wss://c1.calamari.seabird.systems';
const nativeTokenDecimals = 12;

const currentNetwork: interfaces.Network = 'Calamari';
Expand Down Expand Up @@ -85,7 +83,11 @@ const publishTransition = async (
txs: SubmittableExtrinsic<'promise', any>[],
) => {
for (let i = 0; i < txs.length; i++) {
await txs[i].signAndSend(polkadotConfig.polkadotAddress, () => {});
await txs[i].signAndSend(
polkadotConfig.polkadotAddress,
{ nonce: -1 },
() => {},
);
}
};

Expand Down Expand Up @@ -124,7 +126,10 @@ const getBaseWallet = async () => {
return baseWallet;
};

const initWalletData = async (privateWallet: interfaces.IPrivateWallet, initialData = true) => {
const initWalletData = async (
privateWallet: interfaces.IPrivateWallet,
initialData = true,
) => {
_log('Initial signer');
await privateWallet.initialSigner();
_log('Load user mnemonic');
Expand All @@ -139,7 +144,11 @@ const initWalletData = async (privateWallet: interfaces.IPrivateWallet, initialD
const isInitialed = await getIdbData(
`storage_state_${privateWallet.palletName}_${currentNetwork}`,
);
if (newAccountFeatureEnabled && !isInitialed && privateWallet instanceof MantaPayWallet) {
if (
newAccountFeatureEnabled &&
!isInitialed &&
privateWallet instanceof MantaPayWallet
) {
_log('initialNewAccountWalletSync');
await privateWallet.initialNewAccountWalletSync();
} else {
Expand Down Expand Up @@ -270,7 +279,7 @@ const resetData = async (privateWallet: interfaces.IPrivateWallet) => {
await delIdbData(
`storage_state_${privateWallet.palletName}_${currentNetwork}`,
);
}
};

const relaunch = async (privateWallet: interfaces.IPrivateWallet) => {
await resetData(privateWallet);
Expand Down Expand Up @@ -317,7 +326,10 @@ window.actions = {
{ assetId: new BN(startAssetId) },
{ assetId: new BN(startAssetId).add(new BN(1)) },
];
return await multiSbtPostBuild(pallets.mantaSbt as MantaSbtWallet, sbtInfoList);
return await multiSbtPostBuild(
pallets.mantaSbt as MantaSbtWallet,
sbtInfoList,
);
},
async getTransactionDatas(posts: any[]) {
return await getTransactionDatas(pallets.mantaSbt as MantaSbtWallet, posts);
Expand Down
2 changes: 1 addition & 1 deletion manta-js/package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manta-extension-sdk",
"version": "1.0.24",
"version": "1.0.27",
"description": "manta.js sdk",
"main": "./dist/browser/index.js",
"exports": {
Expand Down
8 changes: 4 additions & 4 deletions manta-js/package/src/wallet/crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ disable-restart = []
console_error_panic_hook = { version = "0.1.7", default-features = false }
getrandom = { version = "0.2.8", default-features = false, features = ["js"] }
js-sys = { version = "0.3.60", default-features = false }
manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", tag = "v0.5.16", default-features = false, features = ["serde"] }
manta-crypto = { git = "https://github.com/manta-network/manta-rs.git", tag = "v0.5.16", default-features = false, features = ["serde"] }
manta-pay = { git = "https://github.com/manta-network/manta-rs.git", tag = "v0.5.16", default-features = true, features = ["arkworks", "groth16", "http", "scale", "serde", "wallet"] }
manta-util = { git = "https://github.com/manta-network/manta-rs.git", tag = "v0.5.16", default-features = false, features = ["serde", "reqwest"] }
manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", tag = "v0.5.17", default-features = false, features = ["serde"] }
manta-crypto = { git = "https://github.com/manta-network/manta-rs.git", tag = "v0.5.17", default-features = false, features = ["serde"] }
manta-pay = { git = "https://github.com/manta-network/manta-rs.git", tag = "v0.5.17", default-features = true, features = ["arkworks", "groth16", "http", "scale", "serde", "wallet"] }
manta-util = { git = "https://github.com/manta-network/manta-rs.git", tag = "v0.5.17", default-features = false, features = ["serde", "reqwest"] }
scale-codec = { package = "parity-scale-codec", version = "3.2.1", default-features = false, features = ["derive", "max-encoded-len"] }
serde-wasm-bindgen = { version = "0.4.5", default-features = false }
serde_json = { version = "1.0.89", default-features = false, features = ["alloc", "arbitrary_precision"] }
Expand Down