-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devop: solana wallet-standard connection
- Loading branch information
Showing
30 changed files
with
1,598 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/extension/src/providers/solana/libs/wallet-standard/account.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// This is copied with modification from @wallet-standard/wallet | ||
|
||
import { | ||
SolanaSignAndSendTransaction, | ||
SolanaSignMessage, | ||
SolanaSignTransaction, | ||
} from "@solana/wallet-standard-features"; | ||
import type { WalletAccount } from "@wallet-standard/base"; | ||
import { SOLANA_CHAINS } from "./solana"; | ||
|
||
const chains = SOLANA_CHAINS; | ||
const features = [ | ||
SolanaSignAndSendTransaction, | ||
SolanaSignTransaction, | ||
SolanaSignMessage, | ||
] as const; | ||
|
||
export class EnkryptWalletAccount implements WalletAccount { | ||
readonly #address: WalletAccount["address"]; | ||
readonly #publicKey: WalletAccount["publicKey"]; | ||
readonly #chains: WalletAccount["chains"]; | ||
readonly #features: WalletAccount["features"]; | ||
readonly #label: WalletAccount["label"]; | ||
readonly #icon: WalletAccount["icon"]; | ||
|
||
get address() { | ||
return this.#address; | ||
} | ||
|
||
get publicKey() { | ||
return this.#publicKey.slice(); | ||
} | ||
|
||
get chains() { | ||
return this.#chains.slice(); | ||
} | ||
|
||
get features() { | ||
return this.#features.slice(); | ||
} | ||
|
||
get label() { | ||
return this.#label; | ||
} | ||
|
||
get icon() { | ||
return this.#icon; | ||
} | ||
|
||
constructor({ | ||
address, | ||
publicKey, | ||
label, | ||
icon, | ||
}: Omit<WalletAccount, "chains" | "features">) { | ||
if (new.target === EnkryptWalletAccount) { | ||
Object.freeze(this); | ||
} | ||
|
||
this.#address = address; | ||
this.#publicKey = publicKey; | ||
this.#chains = chains; | ||
this.#features = features; | ||
this.#label = label; | ||
this.#icon = icon; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/extension/src/providers/solana/libs/wallet-standard/icon.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { WalletIcon } from "@wallet-standard/base"; | ||
export const icon: WalletIcon = | ||
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODEiIGhlaWdodD0iODEiIHZpZXdCb3g9IjAgMCA4MSA4MSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNy4wMDU3IDE3LjAwNjJDMTguOTMwMyAxNS4wODE2IDIxLjU0MDUgMTQuMDAwNCAyNC4yNjIyIDE0LjAwMDRMNjcuMzI5NiAxNFYyMS44NzQxQzY3LjMyOTYgMjMuODMwNSA2Ni41NTIzIDI1LjcwNjcgNjUuMTY5IDI3LjA5QzYzLjc4NTcgMjguNDczMyA2MS45MDk1IDI5LjI1MDQgNTkuOTUzMiAyOS4yNTA0SDM5LjcwNDVDMzYuO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9IjE5LjM2MDIiIHkxPSIxNCIgeDI9IjU2Ljc2OTYiIHkyPSI2OS44MDA1IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIHN0b3AtY29sb3I9IiNDNTQ5RkYiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjNjU0QkZGIi8+CjwvbGluZWFyR3JhZGllbnQ+CjwvZGVmcz4KPC9zdmc+Cg=="; |
1 change: 1 addition & 0 deletions
1
packages/extension/src/providers/solana/libs/wallet-standard/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./initialize"; |
8 changes: 8 additions & 0 deletions
8
packages/extension/src/providers/solana/libs/wallet-standard/initialize.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { registerWallet } from "./register"; | ||
import { EnkryptWallet } from "./wallet"; | ||
import type { Enkrypt } from "./window"; | ||
|
||
export function initialize(enkrypt: Enkrypt): void { | ||
console.log(new EnkryptWallet(enkrypt)); | ||
registerWallet(new EnkryptWallet(enkrypt)); | ||
} |
Oops, something went wrong.