Skip to content

Commit

Permalink
feat: switch to new voi testnet (#342)
Browse files Browse the repository at this point in the history
* feat: use function to derive chain reference from genesis hash

* feat: add block to base transaction and rename algorand prefix types

* feat: add new voi testnet with new block explorers

* feat: update what's new modal
  • Loading branch information
kieranroneill authored Oct 30, 2024
1 parent 12a6304 commit a31c253
Show file tree
Hide file tree
Showing 87 changed files with 533 additions and 393 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
} from '../../types';

// utils
import chainReferenceFromGenesisHash from '@extension/utils/chainReferenceFromGenesisHash';
import {
getAccountInformation,
extractWalletConnectNamespaceFromNetwork,
Expand Down Expand Up @@ -132,7 +133,9 @@ export default function useWalletConnectConnector({
try {
return await signClient.request<(string | null)[]>({
topic: session.topic,
chainId: `${network.namespace.key}:${network.namespace.reference}`,
chainId: `${network.namespace.key}:${chainReferenceFromGenesisHash(
network.genesisHash
)}`,
request: {
method:
network.namespace.key === 'algorand'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import type { SessionTypes } from '@walletconnect/types';
// types
import type { INetwork } from '@extension/types';

// utils
import chainReferenceFromGenesisHash from '@extension/utils/chainReferenceFromGenesisHash';

/**
* Extracts the WalletConnect namespace from the network.
* @param {INetwork} network - the network to extract the namespace from.
Expand All @@ -13,7 +16,11 @@ export default function extractWalletConnectNamespaceFromNetwork(
): SessionTypes.BaseNamespace {
return {
accounts: [],
chains: [`${network.namespace.key}:${network.namespace.reference}`],
chains: [
`${network.namespace.key}:${chainReferenceFromGenesisHash(
network.genesisHash
)}`,
],
events: [],
methods: network.namespace.methods,
};
Expand Down
14 changes: 5 additions & 9 deletions dapp-example/utils/getAccountInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { Algodv2, IntDecoding } from 'algosdk';
import BigNumber from 'bignumber.js';

// types
import {
IAlgorandAccountInformation,
IAlgorandAsset,
INetwork,
} from '@extension/types';
import { IAVMAccountInformation, IAVMAsset, INetwork } from '@extension/types';
import { IAccountInformation, IAssetInformation } from '../types';

// utils
Expand All @@ -18,22 +14,22 @@ export default async function getAccountInformation(
network: INetwork
): Promise<IAccountInformation> {
const client: Algodv2 = getRandomAlgodClient(network);
const accountInformation: IAlgorandAccountInformation = (await client
const accountInformation: IAVMAccountInformation = (await client
.accountInformation(account.address)
.setIntDecoding(IntDecoding.BIGINT)
.do()) as IAlgorandAccountInformation;
.do()) as IAVMAccountInformation;
const assets: IAssetInformation[] = await Promise.all(
accountInformation.assets.map<Promise<IAssetInformation>>(
(value, index) =>
new Promise((resolve, reject) =>
setTimeout(async () => {
let assetInformation: IAlgorandAsset;
let assetInformation: IAVMAsset;

try {
assetInformation = (await client
.getAssetByID(Number(value['asset-id']))
.setIntDecoding(IntDecoding.BIGINT)
.do()) as IAlgorandAsset;
.do()) as IAVMAsset;

resolve({
balance: new BigNumber(String(value.amount)),
Expand Down
42 changes: 13 additions & 29 deletions src/extension/config/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { AssetTypeEnum, NetworkTypeEnum } from '@extension/enums';

// models
import AlloBlockExplorer from '@extension/models/AlloBlockExplorer';
import AVMExplorerBlockExplorer from '@extension/models/AVMExplorerBlockExplorer';
import NautilusARC0072Indexer from '@extension/models/NautilusARC0072Indexer';
import NFTNavigatorARC0072Indexer from '@extension/models/NFTNavigatorARC0072Indexer';
import NFTNavigatorNFTExplorer from '@extension/models/NFTNavigatorNFTExplorer';
import PeraBlockExplorer from '@extension/models/PeraBlockExplorer';
import VoiBlockExplorer from '@extension/models/VoiBlockExplorer';
import VoiObserverBlockExplorer from '@extension/models/VoiObserverBlockExplorer';

// types
Expand Down Expand Up @@ -47,6 +47,9 @@ const networks: INetwork[] = [
canonicalName: 'Voi',
chakraTheme: 'voi',
blockExplorers: [
new VoiBlockExplorer({
baseURL: 'https://block.voi.network',
}),
new VoiObserverBlockExplorer({
baseURL: 'https://explorer.voi.network/explorer',
canonicalName: 'Voi Network',
Expand All @@ -70,7 +73,6 @@ const networks: INetwork[] = [
namespace: {
key: 'avm',
methods: ['avm_signTransactions', 'avm_signMessage'],
reference: 'r20fSQI8gWe_kFZziNonSPCXLwcQmH_n',
},
nativeCurrency: {
decimals: 6,
Expand All @@ -94,45 +96,34 @@ const networks: INetwork[] = [
id: null,
port: null,
token: null,
url: 'https://testnet-api.voi.nodly.io',
url: 'https://testnet-api.voi.nodely.dev',
},
],
arc0072Indexers: [
new NautilusARC0072Indexer({
baseURL: 'https://arc72-idx.nautilus.sh',
}),
new NFTNavigatorARC0072Indexer({
baseURL: 'https://arc72-idx.nftnavigator.xyz',
}),
],
arc0072Indexers: [],
canonicalName: 'Voi',
chakraTheme: 'voi',
blockExplorers: [
new VoiObserverBlockExplorer({
baseURL: 'https://voi.observer/explorer',
}),
new AVMExplorerBlockExplorer({
baseURL: 'https://avmexplorer.com',
new VoiBlockExplorer({
baseURL: 'https://testnet.block.voi.network',
}),
],
feeSunkAddress:
'FEES3ZW52HQ7U7LB3OGLUFQX2DCCWPJ2LIMXAH75KYROBZBQRN3Q5OR3GI',
genesisId: 'voitest-v1',
genesisHash: 'IXnoWtviVVJW5LGivNFc0Dq14V3kqaXuK2u5OQrdVZo=',
'TBEIGCNK4UCN3YDP2NODK3MJHTUZMYS3TABRM2MVSI2MPUR2V36E5JYHSY',
genesisId: 'voitest',
genesisHash: '5pbhGq04byd0AgV/sbP+yITANqazgKBuaATr85n21wY=',
indexers: [
{
canonicalName: 'Nodely',
id: null,
port: null,
token: null,
url: 'https://testnet-idx.voi.nodly.io',
url: 'https://testnet-idx.voi.nodely.dev',
},
],
methods: SUPPORTED_METHODS,
namespace: {
key: 'avm',
methods: ['avm_signTransactions', 'avm_signMessage'],
reference: 'IXnoWtviVVJW5LGivNFc0Dq14V3kqaXu',
},
nativeCurrency: {
decimals: 6,
Expand All @@ -142,11 +133,7 @@ const networks: INetwork[] = [
type: AssetTypeEnum.Native,
verified: true,
},
nftExplorers: [
new NFTNavigatorNFTExplorer({
baseURL: 'https://arc72-idx.nftnavigator.xyz',
}),
],
nftExplorers: [],
type: NetworkTypeEnum.Test,
},
/**
Expand Down Expand Up @@ -190,7 +177,6 @@ const networks: INetwork[] = [
namespace: {
key: 'algorand',
methods: ['algo_signTxn'],
reference: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73k',
},
nativeCurrency: {
decimals: 6,
Expand Down Expand Up @@ -234,7 +220,6 @@ const networks: INetwork[] = [
namespace: {
key: 'algorand',
methods: ['algo_signTxn'],
reference: 'mFgazF-2uRS1tMiL9dsj01hJGySEmPN2',
},
nativeCurrency: {
decimals: 6,
Expand Down Expand Up @@ -282,7 +267,6 @@ const networks: INetwork[] = [
namespace: {
key: 'algorand',
methods: ['algo_signTxn'],
reference: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe',
},
nativeCurrency: {
decimals: 6,
Expand Down
8 changes: 4 additions & 4 deletions src/extension/contracts/BaseContract/BaseContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ReadABIContractError } from '@extension/errors';

// types
import type { ILogger } from '@common/types';
import type { IAlgorandAccountInformation } from '@extension/types';
import type { IAVMAccountInformation } from '@extension/types';
import type {
IABIResult,
IBaseApplicationOptions,
Expand Down Expand Up @@ -345,12 +345,12 @@ export default class BaseContract {

/**
* Gets the account information for the account associated with the application.
* @returns {Promise<IAlgorandAccountInformation>} the application's account information.
* @returns {Promise<IAVMAccountInformation>} the application's account information.
*/
public async applicationAccountInformation(): Promise<IAlgorandAccountInformation> {
public async applicationAccountInformation(): Promise<IAVMAccountInformation> {
return (await this._algod
.accountInformation(this.applicationAddress())
.do()) as IAlgorandAccountInformation;
.do()) as IAVMAccountInformation;
}

public async boxByName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import NetworkClient from '@extension/models/NetworkClient';

// types
import type {
IAlgorandSearchApplicationsResult,
IAVMSearchApplicationsResult,
IARC0200Asset,
} from '@extension/types';
import type {
Expand Down Expand Up @@ -57,7 +57,7 @@ const queryARC0200AssetThunk: AsyncThunk<
networks,
settings,
});
let searchApplicationResult: IAlgorandSearchApplicationsResult;
let searchApplicationResult: IAVMSearchApplicationsResult;
let arc200Assets: IARC0200Asset[];
let networkClient: NetworkClient;
let nodeID: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import NetworkClient from '@extension/models/NetworkClient';

// types
import type {
IAlgorandAsset,
IAlgorandSearchAssetsResult,
IAVMAsset,
IAVMSearchAssetsResult,
IStandardAsset,
ITinyManAssetResponse,
} from '@extension/types';
Expand Down Expand Up @@ -59,7 +59,7 @@ const queryStandardAssetThunk: AsyncThunk<
networks,
settings,
});
let searchStandardAssetsResult: IAlgorandSearchAssetsResult;
let searchStandardAssetsResult: IAVMSearchAssetsResult;
let networkClient: NetworkClient;
let verifiedStandardAssets: ITinyManAssetResponse[];
let updatedStandardAssets: IStandardAsset[] = [];
Expand Down Expand Up @@ -127,7 +127,7 @@ const queryStandardAssetThunk: AsyncThunk<
index < searchStandardAssetsResult.assets.length;
index++
) {
const asset: IAlgorandAsset = searchStandardAssetsResult.assets[index];
const asset: IAVMAsset = searchStandardAssetsResult.assets[index];
const verifiedStandardAsset: ITinyManAssetResponse | null =
verifiedStandardAssets.find(
(value) => value.id === String(asset.index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import NetworksRepository from '@extension/repositories/NetworksRepository';

// types
import type {
IAlgorandTransactionParams,
IAVMTransactionParams,
IBaseAsyncThunkConfig,
IMainRootState,
INetworkWithTransactionParams,
Expand All @@ -39,7 +39,7 @@ const updateTransactionParamsForSelectedNetworkThunk: AsyncThunk<
const networks = getState().networks.items;
const online = getState().system.networkConnectivity.online;
const settings = getState().settings;
let avmTransactionParams: IAlgorandTransactionParams;
let avmTransactionParams: IAVMTransactionParams;
let networkClient: NetworkClient;
let network: INetworkWithTransactionParams | null;
let updatedAt: Date;
Expand Down
Loading

0 comments on commit a31c253

Please sign in to comment.