Skip to content

Commit

Permalink
Merge pull request #169 from AElfProject/feature/ecoEarn-support
Browse files Browse the repository at this point in the history
Feature/eco earn support
  • Loading branch information
aelf-lxy authored Oct 21, 2024
2 parents b186594 + 7196729 commit 59b99f5
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 24 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ const baseConfig = {
// cancelAutoLoginInTelegram: false,
enableAcceleration: true,
networkType: NETWORK_TYPE,
chainId: CHAIN_ID,
showVconsole: false,
chainId: CHAIN_ID,
keyboard: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-base",
"version": "0.1.15",
"version": "0.1.17",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export enum LoginStateEnum {
export type TWalletInfo =
| {
name?: string;
address?: string;
address: string;
extraInfo?: {
[key: string]: any;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-bridge",
"version": "0.1.15",
"version": "0.1.17",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/bridge/src/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ const SignInModal: React.FC<ISignInModalProps> = (props: ISignInModalProps) => {
isToggleAccountRef.current = true;
await bridgeInstance.onPortkeyAAUnLock(defaultPin);
await bridgeInstance.doubleCheckDisconnect();
TelegramPlatform.close();
};
TelegramPlatform.initializeTelegramWebApp({ handleLogout });
};
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-react",
"version": "0.1.15",
"version": "0.1.17",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/utils",
"version": "0.1.15",
"version": "0.1.17",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/night-elf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-night-elf",
"version": "0.1.15",
"version": "0.1.17",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
31 changes: 19 additions & 12 deletions packages/wallets/night-elf/src/AelfBridgeCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@ export default class AelfBridgeCheck {
const bridgeInstance = new AElfBridge({
timeout: 3000,
});
bridgeInstance.connect().then((isConnected: boolean) => {
if (timeout) return;
if (isConnected) {
resolve(true);
} else {
reject({
error: 200001,
message: 'timeout, please use AELF Wallet APP or open the page in PC',
});
}
});
console.log('bridgeInstance', bridgeInstance);
bridgeInstance
.connect()
.then((isConnected: boolean) => {
console.log('bridgeInstance isConnected', isConnected);
if (timeout) return;
if (isConnected) {
resolve(true);
} else {
reject({
error: 200001,
message: 'timeout, please use AELF Wallet APP or open the page in PC',
});
}
})
.catch((e: any) => {
console.log('error in catch:', e);
});
setTimeout(() => {
timeout = true;
reject({
Expand Down Expand Up @@ -57,7 +64,7 @@ export default class AelfBridgeCheck {
};
aelfInstanceByBridge.logout = (_: any, callback: () => void) => {
accountInfo = null;
callback();
callback?.();
};
return aelfInstanceByBridge;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/wallets/night-elf/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class NightElfWallet extends BaseWalletAdapter {
}

const result = await defaultAElfBridge.logout({ address });
if (result.error) throw result;
if (result?.error) throw result;

this._wallet = null;
this._loginState = LoginStateEnum.INITIAL;
Expand Down Expand Up @@ -277,7 +277,7 @@ export class NightElfWallet extends BaseWalletAdapter {
contractAddress: contractAddress,
aelfInstance: bridge,
account: {
address: this._wallet.address!,
address: this._wallet.address,
},
});
}
Expand Down
8 changes: 8 additions & 0 deletions packages/wallets/night-elf/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,29 @@ export const getBridges = async (nodes: INightElfWalletAdapterConfig['nodes'], a
const { isMobile } = utils;
try {
const isAElfBridge = isMobile() && !(window as any)?.NightElf;
console.log('aelf-wallet-debug----------1');
console.log(`isMobile(): ${isMobile()}`);
console.log(`(window as any)?.NightElf: ${(window as any)?.NightElf}`);

const connector = (
await (isAElfBridge ? import('./AelfBridgeCheck') : import('./NightElfCheck'))
).default;
console.log('connector', connector);
// check connector
await connector.getInstance().check();
console.log('aelf-wallet-debug----------2');

let firstKey = '';
const bridges: { [key: string]: AElfDappBridge } = {};
console.log('nodes:', nodes);
if (!nodes || Object.keys(nodes).length === 0) {
throw makeError(ERR_CODE.INIT_BRIDGE_ERROR);
}
Object.entries(nodes).forEach(([k, v]) => {
if (!firstKey) firstKey = k;
bridges[k] = connector.initAelfInstanceByExtension(v.rpcUrl, appName);
});
console.log('aelf-wallet-debug----------3');
const node = nodes[firstKey];
const bridge = bridges[firstKey];
return { bridge, node, bridges };
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/portkey-aa/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-portkey-aa",
"version": "0.1.15",
"version": "0.1.17",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
4 changes: 4 additions & 0 deletions packages/wallets/portkey-aa/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export class PortkeyAAWallet extends BaseWalletAdapter {
this.autoRequestAccountHandler();
}

setChainId(chainId: TChainId) {
this._config.chainId = chainId;
}

get loginState() {
return this._loginState;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/portkey-discover/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-portkey-discover",
"version": "0.1.15",
"version": "0.1.17",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/portkey-discover/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export class PortkeyDiscoverWallet extends BaseWalletAdapter {
}
const finalChainId = chainId || this._chainId;
const contract = await this.getContract(finalChainId, contractAddress);
const rs = contract.callSendMethod(methodName, this._wallet.address!, args, sendOptions);
const rs = contract.callSendMethod(methodName, this._wallet.address, args, sendOptions);
return rs as R;
}

Expand Down

0 comments on commit 59b99f5

Please sign in to comment.