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

refactor: Created utils package #265

Merged
merged 19 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9b8b784
Created basic package, exported isMobile method and replaced is-mobi…
amirsaran3 Apr 18, 2022
eb94625
Fixed parseBigNumber and parseNearAmount
amirsaran3 Apr 20, 2022
56d1f44
Merge branch 'dev' of https://github.com/near-projects/wallet-selecto…
amirsaran3 Apr 25, 2022
83eda63
Merge branch 'dev' of https://github.com/near-projects/wallet-selecto…
amirsaran3 Apr 28, 2022
d35b4f8
Added createAction and createTransaction
amirsaran3 Apr 28, 2022
9c3a5a3
Added createTransaction to near-wallet
amirsaran3 Apr 28, 2022
e05b6d9
Resolved conflicts with dev
amirsaran3 May 9, 2022
eb79fbe
Created wallet-utils package, added signTransactions
amirsaran3 May 11, 2022
e67d9ae
Fixed build errors, removed parse methods
amirsaran3 May 11, 2022
72d9401
Fixed math-wallet and ledger implementations of signTransactions
amirsaran3 May 11, 2022
2f137c0
Removed utils package, split up wallet-utils.ts, removed wallet.ts
amirsaran3 May 12, 2022
b610a4b
Adjusted param type of signTransactions method
amirsaran3 May 16, 2022
980cab1
Resolved conflicts
amirsaran3 May 16, 2022
20952dc
Fixed issue with rpc networkId
amirsaran3 May 16, 2022
4112715
Changed createAction param to be object not array
amirsaran3 May 16, 2022
3dff3d4
Removed accountId param from signTransactions
amirsaran3 May 16, 2022
3d88778
Fixed wallet-utils test
amirsaran3 May 16, 2022
d270d9c
Fixed defaulting for signing transactions
amirsaran3 May 16, 2022
2a3837b
Defaulted to first account when signerId not provided
amirsaran3 May 17, 2022
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: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"build:near-wallet": "nx run-many --target=build --projects=near-wallet --configuration=production",
"build:sender": "nx run-many --target=build --projects=sender --configuration=production",
"build:wallet-connect": "nx run-many --target=build --projects=wallet-connect --configuration=production",
"build:utils": "nx run-many --target=build --projects=utils --configuration=production",
"build:wallet-utils": "nx run-many --target=build --projects=wallet-utils --configuration=production",
"lint": "nx workspace-lint && nx run-many --target=lint --all --parallel",
"lint:fix": "nx run-many --target=lint --all --fix",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export { setupWalletSelector } from "./lib/wallet-selector";
export { ModalOptions, Theme } from "./lib/modal/modal.types";

export { Network, NetworkId } from "./lib/options.types";
export { Subscription, ProviderService } from "./lib/services";
export { Subscription } from "./lib/services";
export { Optional } from "./lib/utils.types";

export {
Expand Down
118 changes: 0 additions & 118 deletions packages/core/src/lib/wallet/wallet.ts

This file was deleted.

4 changes: 1 addition & 3 deletions packages/ledger/src/lib/ledger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isMobile } from "is-mobile";
import { TypedError } from "near-api-js/lib/utils/errors";
import { isMobile } from "@near-wallet-selector/utils";
import { signTransactions } from "@near-wallet-selector/wallet-utils";
import {
WalletModuleFactory,
Expand Down Expand Up @@ -248,7 +248,6 @@ const Ledger: WalletBehaviourFactory<HardwareWallet> = async ({
},
],
signer,
provider,
_state.authData.accountId
);

Expand All @@ -268,7 +267,6 @@ const Ledger: WalletBehaviourFactory<HardwareWallet> = async ({
const signedTransactions = await signTransactions(
transactions,
signer,
provider,
_state.authData.accountId
);

Expand Down
4 changes: 1 addition & 3 deletions packages/math-wallet/src/lib/math-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isMobile } from "@near-wallet-selector/utils";
import { isMobile } from "is-mobile";
import {
WalletModuleFactory,
WalletBehaviourFactory,
Expand Down Expand Up @@ -121,7 +121,6 @@ const MathWallet: WalletBehaviourFactory<InjectedWallet> = async ({
},
],
_state.wallet.signer,
provider,
account.accountId
);

Expand Down Expand Up @@ -149,7 +148,6 @@ const MathWallet: WalletBehaviourFactory<InjectedWallet> = async ({
const signedTransactions = await signTransactions(
transactions,
_state.wallet.signer,
provider,
accountId
);

Expand Down
26 changes: 16 additions & 10 deletions packages/near-wallet/src/lib/near-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { WalletConnection, connect, keyStores } from "near-api-js";
import {
WalletConnection,
connect,
keyStores,
transactions as nearTransactions,
utils,
} from "near-api-js";
import {
WalletModuleFactory,
WalletBehaviourFactory,
Expand All @@ -7,7 +13,6 @@ import {
Optional,
Network,
} from "@near-wallet-selector/core";
import { createTransaction } from "@near-wallet-selector/utils";
import { createAction } from "@near-wallet-selector/wallet-utils";

export interface NearWalletParams {
Expand Down Expand Up @@ -95,6 +100,7 @@ const NearWallet: WalletBehaviourFactory<

return Promise.all(
transactions.map(async (transaction, index) => {
const actions = createAction(transaction.actions);
const accessKey = await account.accessKeyForTransaction(
transaction.receiverId,
createAction(transaction.actions),
Expand All @@ -109,14 +115,14 @@ const NearWallet: WalletBehaviourFactory<

const block = await provider.block({ finality: "final" });

return createTransaction({
accountId: account.accountId,
publicKey: accessKey.public_key,
receiverId: transaction.receiverId,
nonce: accessKey.access_key.nonce + index + 1,
actions: transaction.actions,
hash: block.header.hash,
});
return nearTransactions.createTransaction(
account.accountId,
utils.PublicKey.from(accessKey.public_key),
transaction.receiverId,
accessKey.access_key.nonce + index + 1,
actions,
utils.serialize.base_decode(block.header.hash)
);
})
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/sender/src/lib/sender.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isMobile } from "@near-wallet-selector/utils";
import { isMobile } from "is-mobile";
import {
WalletModuleFactory,
WalletBehaviourFactory,
Expand Down
3 changes: 0 additions & 3 deletions packages/utils/.babelrc

This file was deleted.

18 changes: 0 additions & 18 deletions packages/utils/.eslintrc.json

This file was deleted.

10 changes: 0 additions & 10 deletions packages/utils/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions packages/utils/jest.config.js

This file was deleted.

4 changes: 0 additions & 4 deletions packages/utils/package.json

This file was deleted.

42 changes: 0 additions & 42 deletions packages/utils/project.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/utils/src/index.ts

This file was deleted.

35 changes: 0 additions & 35 deletions packages/utils/src/lib/utils.ts

This file was deleted.

19 changes: 0 additions & 19 deletions packages/utils/tsconfig.json

This file was deleted.

Loading