Skip to content

Commit

Permalink
Merge pull request #658 from TokenScript/OH_ultra
Browse files Browse the repository at this point in the history
feat: 🎸 added support for Ultra blockchain. can support WAX,EOS
  • Loading branch information
nicktaras authored Jul 26, 2023
2 parents 19dddf3 + a603001 commit 410022d
Show file tree
Hide file tree
Showing 13 changed files with 436 additions and 18 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,14 @@ Configure the library using the following example.
chain: "eth",
blockchain: "evm",
},
{
blockchain: "ultra",
onChain: true,
collectionID: "ultranft",
contract: "eosio.nft.ft", // static
chain: "testnet", // testnet or mainnet
factoryId: 2669 // most important value, describes NFT collection
},
{
hideToggle: true,
noTokenMsg:
Expand Down
242 changes: 242 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"@walletconnect/types": "^2.1.5",
"@walletconnect/universal-provider": "^2.4.5",
"@walletconnect/web3-provider": "^1.7.1",
"eosjs": "^22.1.0",
"eosjs-ecc": "^4.0.7",
"ethers": "^5.4.0",
"pvutils": "^1.0.17",
"text-encoding": "^0.7.0",
Expand Down
9 changes: 6 additions & 3 deletions src/client/auth/signedUNChallenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export class SignedUNChallenge extends AbstractAuthentication implements Authent
this.deleteProof(address)
currentProof = null
}
}

if (!currentProof) {
} else {
let walletConnection = connection.provider

currentProof = {
Expand All @@ -55,6 +53,11 @@ export class SignedUNChallenge extends AbstractAuthentication implements Authent
signature = await web3WalletProvider.signMessage(address, challenge.messageToSign)
}

const publicKeys = connection.meta?.publicKeys
if (publicKeys?.length) {
// ultra allows single key only
challenge.publicKey = publicKeys[0];
}
challenge.signature = signature
challenge.blockchain = connection.blockchain
if (!(await UN.verifySignature(challenge))) {
Expand Down
6 changes: 5 additions & 1 deletion src/client/auth/util/UN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ethers } from 'ethers'
import { sign } from 'tweetnacl'
import { base58ToUint8Array, hexStringToUint8Array, strToHexStr, strToUtfBytes } from '../../../utils'
import * as flowTypes from '@onflow/types'
import * as ecc from 'eosjs-ecc'

export interface UNInterface {
expiration: number
Expand All @@ -12,6 +13,7 @@ export interface UNInterface {
address?: string
signature?: string
blockchain?: string
publicKey?: string
}

export class UN {
Expand Down Expand Up @@ -44,7 +46,9 @@ export class UN {
public static async verifySignature(un: UNInterface) {
if (!un.signature) throw new Error('Null signature')

if (un.blockchain === 'solana') {
if (un.blockchain === 'ultra') {
return ecc.verify(un.signature, un.messageToSign, un.publicKey)
} else if (un.blockchain === 'solana') {
return await sign.detached.verify(
strToUtfBytes(un.messageToSign),
hexStringToUint8Array(un.signature),
Expand Down
Loading

0 comments on commit 410022d

Please sign in to comment.