Skip to content

Commit

Permalink
Telos support in EVM bridge (#168)
Browse files Browse the repository at this point in the history
* fix: catching metamask error when funds are insufficient

closes issue #166

* chore: adding support for Telos EVM

* refactor: using transferTypes object to determine how different transfers should be processed

* refactor: putting all evm transfer logic in evm specific classes

* fix: getting page running again

* refactor: refactored transfer page to use manager classes

* fix: getting page running again

* refactor: using the get method to get store values

* chore: added telos evm bridge methods

* fix: getting telos bridge working

* fix: connecting to evm wallet for telos bridge

* enhancement: handling case where enter is pressed in the transfer form

* chore: getting the telos page working

* style: linted

* fix: using correct evm network for telos bridge

* enhancement: polished evm network switching

* fix: catching error when fee makes transfer exceed balance

* fix: making network switching more robust
  • Loading branch information
dafuga authored Sep 20, 2023
1 parent f76005f commit c28df19
Show file tree
Hide file tree
Showing 18 changed files with 947 additions and 321 deletions.
23 changes: 23 additions & 0 deletions src/abi-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
UInt16,
UInt32,
UInt64,
Checksum160,
} from 'anchor-link'

@Struct.type('buyrambytes')
Expand Down Expand Up @@ -170,3 +171,25 @@ export class Transfer extends Struct {
@Struct.field('asset') quantity!: Asset
@Struct.field('string') memo!: string
}

@Struct.type('withdraw')
export class TelosEvmWithdraw extends Struct {
@Struct.field('name') to!: Name
@Struct.field('asset') quantity!: Asset
}

@Struct.type('openwallet')
export class TelosEvmOpenWallet extends Struct {
@Struct.field('name') account!: Name
@Struct.field('checksum160') address!: Checksum160
@Struct.field('name') actor!: Name
@Struct.field('name') permission!: Name
}

@Struct.type('create')
export class TelosEvmCreate extends Struct {
@Struct.field('name') account!: Name
@Struct.field('string') data!: string
@Struct.field('name') actor!: Name
@Struct.field('name') permission!: Name
}
8 changes: 7 additions & 1 deletion src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {get} from 'svelte/store'
import {storeAccount} from './stores/account-provider'
import {getClient} from './api-client'
import {appId, chains} from './config'
import {activeSession, availableSessions} from './store'
import {activeEvmSession, activeSession, availableSessions} from './store'
import {startEvmSession} from './lib/evm'

const transport = new Transport({
requestStatus: false,
Expand Down Expand Up @@ -97,4 +98,9 @@ export async function activate(id: SessionLike) {
throw new Error('No such session')
}
activeSession.set(session)

if (get(activeEvmSession)) {
activeEvmSession.set(undefined)
startEvmSession()
}
}
2 changes: 0 additions & 2 deletions src/components/elements/form/transaction.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
},
clear: () => {
error = false
console.log('clearing')
transaction_id.set(undefined)
},
retryTransaction: () => {
Expand All @@ -73,7 +72,6 @@
}
},
setTransaction: (id: string) => {
console.log('setting')
transaction_id.set(id)
},
setTransactionError: (err: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export const chains: ChainConfig[] = [
resourceSampleAccount: 'greymassfuel',
resourceSampleMilliseconds: 1000,
testnet: false,
bloksUrl: 'https://telos.bloks.io',
bloksUrl: 'https://explorer.telos.net',
balanceProviders: new Set([BalanceProviders.LightAPI]),
},
{
Expand Down
Loading

0 comments on commit c28df19

Please sign in to comment.