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

feat: add okx bitcoin connector #3408

Merged
merged 13 commits into from
Dec 9, 2024
Merged

feat: add okx bitcoin connector #3408

merged 13 commits into from
Dec 9, 2024

Conversation

zoruka
Copy link
Contributor

@zoruka zoruka commented Dec 6, 2024

Description

Adds Bitcoin OKX Wallet connector.

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-1687

Showcase (Optional)

If there is a UI change include the screenshots with before and after state.
If new feature is being introduced, include the link to demo recording.

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

changeset-bot bot commented Dec 6, 2024

🦋 Changeset detected

Latest commit: 85f3ce7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@reown/appkit-scaffold-ui Patch
@reown/appkit Patch
@reown/appkit-core Patch
@reown/appkit-ui Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit-utils Patch
@reown/appkit-cdn Patch
appkit-cli Patch
@reown/appkit-common Patch
@reown/appkit-experimental Patch
@reown/appkit-polyfills Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-wallet Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
appkit-builder ❌ Failed (Inspect) Dec 9, 2024 9:34pm
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 9:34pm
appkit-vue-solana ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 9:34pm
appkit-wagmi-cdn-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 9:34pm
vue-wagmi-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 9:34pm

Copy link
Contributor

github-actions bot commented Dec 6, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 50.79% 13364 / 26309
🔵 Statements 50.79% 13364 / 26309
🔵 Functions 37.74% 942 / 2496
🔵 Branches 75.06% 1553 / 2069
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/adapters/bitcoin/src/connectors/OKXConnector.ts 100% 100% 100% 100%
packages/adapters/bitcoin/src/utils/UnitsUtil.ts 100% 100% 100% 100%
Generated in workflow #7960 for commit 85f3ce7 by the Vitest Coverage Report Action

Copy link

linear bot commented Dec 9, 2024

Comment on lines +127 to +140
if (bitcoinPSBTUtils.isP2MS(output)) {
return bitcoin.payments.p2ms({ output, network })
} else if (bitcoinPSBTUtils.isP2PK(output)) {
return bitcoin.payments.p2pk({ output, network })
} else if (bitcoinPSBTUtils.isP2PKH(output)) {
return bitcoin.payments.p2pkh({ output, network })
} else if (bitcoinPSBTUtils.isP2WPKH(output)) {
return bitcoin.payments.p2wpkh({ output, network })
} else if (bitcoinPSBTUtils.isP2WSHScript(output)) {
return bitcoin.payments.p2wsh({ output, network })
} else if (bitcoinPSBTUtils.isP2SHScript(output)) {
return bitcoin.payments.p2sh({ output, network })
} else if (bitcoinPSBTUtils.isP2TR(output)) {
return bitcoin.payments.p2tr({ output, network })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe nit: can we do a switch or even an object mapping for this?
eg

switch {
   case(bitcoinPSBTUtils.isP2MS(output)):
      ...
}

Not sure this works in js but wall of if looks ugly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know this is not possible syntax wise, switch expects a value to match the value in each case. As we need to check through functions I don't think it is possible to use switch in this case.

@@ -32,6 +32,7 @@
"@wallet-standard/app": "1.0.1",
"@wallet-standard/base": "1.0.1",
"@walletconnect/universal-provider": "2.17.0",
"bitcoinjs-lib": "7.0.0-rc.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the rc version for this?

public readonly chain = 'bip122'
public readonly type = 'ANNOUNCED'
public readonly imageUrl =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJDSURBVHgB7Zq9jtpAEMfHlhEgQLiioXEkoAGECwoKxMcTRHmC5E3IoyRPkPAEkI7unJYmTgEFTYwA8a3NTKScLnCHN6c9r1e3P2llWQy7M/s1Gv1twCP0ej37dDq9x+Zut1t3t9vZjDEHIiSRSPg4ZpDL5fxkMvn1cDh8m0wmfugfO53OoFQq/crn8wxfY9EymQyrVCqMfHvScZx1p9ls3pFxXBy/bKlUipGPrVbLuQqAfsCliq3zl0H84zwtjQrOw4Mt1W63P5LvBm2d+Xz+YzqdgkqUy+WgWCy+Mc/nc282m4FqLBYL+3g8fjDxenq72WxANZbLJeA13zDX67UDioL5ybXwafMYu64Ltn3bdDweQ5R97fd7GyhBQMipx4POeEDHIu2LfDdBIGGz+hJ9CQ1ABjoA2egAZPM6AgiCAEQhsi/C4jHyPA/6/f5NG3Ks2+3CYDC4aTccDrn6ojG54MnEvG00GoVmWLIRNZ7wTCwDHYBsdACy0QHIhiuRETxlICWpMMhGZHmqS8qH6JLyGegAZKMDkI0uKf8X4SWlaZo+Pp1bRrwlJU8ZKLIvUjKh0WiQ3sRUbNVq9c5Ebew7KEo2m/1p4jJ4qAmDaqDQBzj5XyiAT4VCQezJigAU+IDU+z8vJFnGWeC+bKQV/5VZ71FV6L7PA3gg3tXrdQ+DgLhC+75Wq3no69P3MC0NFQpx2lL04Ql9gHK1bRDjsSBIvScBnDTk1WrlGIZBorIDEYJj+rhdgnQ67VmWRe0zlplXl81vcyEt0rSoYDUAAAAASUVORK5CYII='
Copy link
Collaborator

@tomiir tomiir Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a proper image from design?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a change to get the icon from the extension

Comment on lines 72 to 73
const value = (Number(params.amount) / 10 ** network.nativeCurrency.decimals).toString()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit succeptible to breaking. can we do a utils to parse the value?
something like ethers does with parseUnit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants