-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Tezos Provider #1
Conversation
1b4c23a
to
e5cfdec
Compare
.prettierrc
Outdated
@@ -0,0 +1,6 @@ | |||
{ | |||
"tabWidth": 2, |
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.
it's more of an editorconfig thing
.prettierrc
Outdated
@@ -0,0 +1,6 @@ | |||
{ | |||
"tabWidth": 2, | |||
"useTabs": false, |
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.
and this
.prettierrc
Outdated
"tabWidth": 2, | ||
"useTabs": false, | ||
"trailingComma": "all", | ||
"printWidth": 100 |
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.
and this
eslint.config.mjs
Outdated
}, | ||
files: ["**/*.ts"], | ||
rules: { | ||
"@typescript-eslint/ban-ts-ignore": ["off"], |
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.
are you confident of turning all of those off?
package.json
Outdated
], | ||
"scripts": { | ||
"clean": "rm -rf dist", | ||
"build": "tsup-node --dts", |
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.
you can puts the dts setting into the tsup config itself down below
src/TezosProvider.ts
Outdated
return await this.tezosSend(op); | ||
}; | ||
|
||
public tezosSendProposal = async (op: TezosProposalOperation): Promise<TezosSendResponse> => { |
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.
not sure if all those methods need the tezos prefix. it's obvious from the class name that it's tezos related
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.
The operations contain the names of WalletConnect requests: tezos_send
, tezos_sign
, tezos_getaccounts
.
I try to find a way to distinguish requests to peer (on top of these 3) and auxilary requests, like getBalance()
, connect()
, getContractAddress()
.
If you think, that it's not needed, I'll rename:
tezosSend -> send
tezosSign -> sign
tezosGetAccounts -> getAccounts
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.
yeah, I don't think it adds much value
src/TezosProvider.ts
Outdated
return await this.tezosSend(op); | ||
}; | ||
|
||
public tezosSendIncreasePaidStorage = async ( |
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.
there is no need to await unless you want to catch errors or something. so it should be
public async sendIncreasePaidStorage(op: PartialTezosIncreasePaidStorageOperation) {
return this.tezosSend(op);
}
package.json
Outdated
}, | ||
"devDependencies": { | ||
"@jest/globals": "^29.7.0", | ||
"@swc/core": "^1.7.35", |
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.
so do you use swc or tsup in the end?
tsconfig.json
Outdated
"ignoreDeprecations": "5.0" | ||
|
||
}, | ||
"include": ["./src/**/*.ts", "./src"], |
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.
"include": ["src"]
tsconfig.json
Outdated
"include": ["./src/**/*.ts", "./src"], | ||
"exclude": [ | ||
"node_modules", | ||
"test", |
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.
don't exclude test
f94006b
to
630dc2f
Compare
630dc2f
to
1b40b6f
Compare
tsconfig.json
Outdated
|
||
}, | ||
"include": ["src"], | ||
"exclude": [ |
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.
not needed
"lib": ["ES2020", "DOM"], | ||
"module": "ES2020", | ||
"target": "ES2020", | ||
"moduleResolution": "Node", |
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.
why node if that's a front-end app? 🤔
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.
I used WalletConnect monorepo as a reference. There is a number of providers and all of them used main config:
https://github.com/WalletConnect/walletconnect-monorepo/blob/v2.0/tsconfig.json#L18
"lib": ["ES2020", "DOM"],
"module": "ES2020",
"target": "ES2020",
"moduleResolution": "Node",
I try to keep my code aligned.
package.json
Outdated
"package.json": "^2.0.1", | ||
"rollup": "^4.24.0", | ||
"typescript": "^5.6.3", | ||
"yarn.lock": "^0.0.1-security" |
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.
?
package.json
Outdated
"type": "module", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.es.js", | ||
"unpkg": "dist/index.umd.js", |
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.
do you have it?
package.json
Outdated
"test:pre": "rm -rf ./test/test.db", | ||
"test:run": "jest", | ||
"test": "yarn test:pre; yarn test:run", | ||
"prettier": "prettier --check '{src,test}/**/*.{js,ts,jsx,tsx}' --write", |
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.
just prettier --write .
package.json
Outdated
"test:run": "jest", | ||
"test": "yarn test:pre; yarn test:run", | ||
"prettier": "prettier --check '{src,test}/**/*.{js,ts,jsx,tsx}' --write", | ||
"lint": "eslint -c 'eslint.config.mjs' --fix './src/**/*.ts'", |
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.
IIRC eslint 9 (which config you are using) has the list of files already.
no need to use quotes
package.json
Outdated
}, | ||
"dependencies": { | ||
"@airgap/beacon-types": "^4.2.2", | ||
"@taquito/rpc": "~20.0.1", |
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.
outdated, use yarn upgrade-interactive
to fix such things
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.
fixed deps. Checked that lib is built in WalletConnect example for tezos provider
package.json
Outdated
"@walletconnect/logger": "^2.1.2", | ||
"@walletconnect/types": "2.13.3", | ||
"@walletconnect/universal-provider": "^2.17.1", | ||
"axios": "^1.7.7", |
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.
you use it in only 1 place. consider replacing with a built-in fetch
. less dependencies -> smaller output
], | ||
"scripts": { | ||
"clean": "rm -rf dist", | ||
"build": "tsup-node", |
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.
since it's a library, most likely you need to either us tsup
or tsup-node
+ peerDependencies
in the package.json
22b88e9
to
8e6fc54
Compare
package.json
Outdated
"@walletconnect/logger": "^2.1.2", | ||
"@walletconnect/types": "^2.17.2", | ||
"@walletconnect/universal-provider": "^2.17.2", | ||
"i": "^0.3.7", |
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.
??
8e6fc54
to
8188e4c
Compare
8188e4c
to
48319c8
Compare
test/jest.setup.js
Outdated
@@ -0,0 +1,3 @@ | |||
global.fetch = jest.fn(); | |||
|
|||
jest.clearAllMocks(); |
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.
put this into jest.config
test/index.spec.ts
Outdated
} as TezosProviderOpts); | ||
await provider.connect({ chains: [TezosChainDataMainnet] }); | ||
|
||
// mockRequest = jest.fn(); |
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.
not needed
test/index.spec.ts
Outdated
const mockRequest = jest.fn(); | ||
|
||
beforeEach(async () => { | ||
(UniversalProvider.init as jest.Mock).mockResolvedValue({ |
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.
jest.mocked(...) is a type safe version. please prefer it (and in other places too)
d0598bc
to
feb596c
Compare
feb596c
to
2155a0b
Compare
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.
LGTM!
Adding Tezos Provider for WalletConnect SDK.
See README for usage examples.
Usage example: reown-com/web-examples#697
Testing:
Moved tezosProvider from WalletConnect Monorepo, PR#5357