Skip to content

[WIP] feat: multichain support #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 46 commits into
base: feat/onramp
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
75b93f1
chore: cloned scaffold and renamed to appkit-react-native
ignaciosantise Apr 8, 2025
aebda1c
chore: connect with basic ethers adapter
ignaciosantise Apr 9, 2025
4c95fae
chore: moved connectionscontroller to core, moved types to common
ignaciosantise Apr 9, 2025
3777d02
chore: restore session
ignaciosantise Apr 10, 2025
bc0ac74
chore: getting account balance from adapter
ignaciosantise Apr 11, 2025
ceb3156
chore: implemented missing functions in wagmi adapter
ignaciosantise Apr 11, 2025
a8e11d2
chore: get balance/switch network
ignaciosantise Apr 29, 2025
cf88456
chore: added basic solana adapter. getting account balances
ignaciosantise Apr 30, 2025
ddf374b
chore: removed unnecesary adapter methods, getting balance
ignaciosantise May 2, 2025
d352090
chore: added solana and ethers actions to sample app
ignaciosantise May 2, 2025
9021e56
chore: filter accountChanged
ignaciosantise May 2, 2025
112d665
chore: solved issue with balance
ignaciosantise May 2, 2025
11f1071
chore: improvements and added bitcoin basic adapter
ignaciosantise May 5, 2025
8da083a
chore: added clipboard client option
ignaciosantise May 5, 2025
f7fb6c1
chore: code improvements
ignaciosantise May 6, 2025
d9d690f
chore: added events and walletinfo hooks
ignaciosantise May 6, 2025
384abc9
chore: improved hooks
ignaciosantise May 6, 2025
886a216
chore: added default chain prop
ignaciosantise May 7, 2025
fe895b2
chore: type change
ignaciosantise May 7, 2025
c3051ef
chore: type fix
ignaciosantise May 8, 2025
0175ea0
chore: removed ethers client
ignaciosantise May 8, 2025
3d06ddf
chore: removed scaffold package
ignaciosantise May 8, 2025
33f77f1
chore: added wagmi connector + added common methods to blockchain ada…
ignaciosantise May 9, 2025
3451bb9
chore: removed common code of adapters, getting balance in chainChang…
ignaciosantise May 9, 2025
9c8570f
chore: improved wagmi connector
ignaciosantise May 12, 2025
71d6bb6
chore: fixed tests
ignaciosantise May 12, 2025
7f6621d
chore: changed lockfile
ignaciosantise May 12, 2025
ac50389
chore: changeset file
ignaciosantise May 12, 2025
6158106
chore: removed onramp changeset file
ignaciosantise May 12, 2025
35c5407
chore: changed snapshot action to create a package if it doesn't exist
ignaciosantise May 12, 2025
212fdfd
chore: modified snapshot action
ignaciosantise May 13, 2025
ddb535e
chore: modified snapshot action
ignaciosantise May 13, 2025
c8c2372
chore: modified snapshot action
ignaciosantise May 13, 2025
51e4bfb
chore: modified snapshot action
ignaciosantise May 13, 2025
bc514ee
chore: modified snapshot action
ignaciosantise May 13, 2025
10f5ec6
chore: modified snapshot action
ignaciosantise May 13, 2025
18d4aaa
chore: modified snapshot action
ignaciosantise May 13, 2025
e5d4e47
chore: replaced solana lib with fetch because of polyfill issue
ignaciosantise May 14, 2025
26aaeca
chore: checking for appkit instance in exported hooks
ignaciosantise May 15, 2025
d08f6cb
chore: removed ethers as a dependency for ethers adapter
ignaciosantise May 15, 2025
3c8618f
chore: enable activity list only for solana and evm
ignaciosantise May 15, 2025
10ca992
chore: fixed switchchain on wagmi connector
ignaciosantise May 15, 2025
63dd67e
chore: removed request method from adapters
ignaciosantise May 15, 2025
5a2ee6e
chore: added types to events
ignaciosantise May 15, 2025
e31429d
chore: updated lockfile
ignaciosantise May 16, 2025
b3eed6e
chore: solved wagmi issue when switching chain
ignaciosantise May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/forty-zoos-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@reown/appkit-scaffold-utils-react-native': major
'@reown/appkit-bitcoin-react-native': major
'@reown/appkit-ethers5-react-native': major
'@reown/appkit-react-native': major
'@reown/appkit-common-react-native': major
'@reown/appkit-ethers-react-native': major
'@reown/appkit-solana-react-native': major
'@reown/appkit-wagmi-react-native': major
'@reown/appkit-core-react-native': major
'@reown/appkit-siwe-react-native': major
'@reown/appkit-ui-react-native': major
'@reown/appkit-auth-ethers-react-native': major
'@reown/appkit-auth-wagmi-react-native': major
'@reown/appkit-coinbase-ethers-react-native': major
'@reown/appkit-coinbase-wagmi-react-native': major
'@reown/appkit-wallet-react-native': major
---

feat: added multichain support
18 changes: 0 additions & 18 deletions .changeset/slimy-apricots-complain.md

This file was deleted.

170 changes: 170 additions & 0 deletions .github/scripts/publish-initial-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
const { execSync, spawnSync } = require('child_process');
const fs = require('fs');
const path = require('path');

// Helper function to run commands and handle errors
function runCommand(command, args, options) {
console.log(
`Executing: ${command} ${args.join(' ')} ${options && options.cwd ? `in ${options.cwd}` : ''}`
);
const result = spawnSync(command, args, { stdio: 'inherit', ...options });
if (result.error) {
console.error(`Error executing ${command}:`, result.error);
throw result.error;
}
if (result.status !== 0) {
const message = `Command failed: ${command} ${args.join(' ')} exited with status ${
result.status
}`;
console.error(message);
throw new Error(message);
}
return result;
}

console.log('Starting initial package publishing process...');

let packagesToPublish = [];
const rootDir = process.cwd();

const packagesToExclude = ['@apps/native', '@apps/gallery', 'appkit-react-native'];

try {
// Get workspace info using yarn workspaces list --json
// Yarn v1 outputs newline-delimited JSON objects
const rawOutput = execSync('yarn workspaces list --json', { encoding: 'utf8' });
const lines = rawOutput
.trim()
.split('\n')
.filter(line => line.trim() !== '');
const workspacePackages = lines.map(line => JSON.parse(line));

for (const pkgData of workspacePackages) {
console.log(`[DEBUG] Processing workspace entry: ${JSON.stringify(pkgData)}`);

// Skip the root package (identified by location '.') or any package without a defined location
if (pkgData.location === '.' || !pkgData.location) {
console.log(
`[DEBUG] Skipping root or undefined location package: ${pkgData.name} at ${pkgData.location}`
);
continue;
}

// Skip excluded packages
if (packagesToExclude.includes(pkgData.name)) {
console.log(`Skipping excluded package: ${pkgData.name}`);
continue;
}

const pkgName = pkgData.name;
const pkgDir = path.resolve(rootDir, pkgData.location);

// Check if package exists on npm
console.log(`Checking NPM status for ${pkgName}...`);
const npmViewResult = spawnSync('npm', ['view', pkgName, 'version'], { encoding: 'utf8' });

// If npm view exits with 0 and has output, package exists.
// Otherwise (non-zero exit or empty output), it likely doesn't.
if (npmViewResult.status === 0 && npmViewResult.stdout && npmViewResult.stdout.trim() !== '') {
console.log(
`Package ${pkgName} (version: ${npmViewResult.stdout.trim()}) already exists on NPM. Skipping initial publish.`
);
} else {
console.log(
`Package ${pkgName} does not appear to exist on NPM or has no published versions.`
);
if (fs.existsSync(path.join(pkgDir, 'package.json'))) {
const packageJsonContent = fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf8');
const parsedPackageJson = JSON.parse(packageJsonContent);
console.log(
`[DEBUG] package.json for ${pkgName}: private=${parsedPackageJson.private}, version=${parsedPackageJson.version}`
); // Added for debugging
packagesToPublish.push({ name: pkgName, dir: pkgDir });
} else {
console.warn(`Skipping ${pkgName}: package.json not found in ${pkgDir}`);
}
}
}
} catch (error) {
console.error('Error processing workspace info or checking NPM status:', error.message);
process.exit(1); // Critical error, exit
}

if (packagesToPublish.length === 0) {
console.log('No new packages to publish initially.');
} else {
console.log(
`Found ${packagesToPublish.length} new package(s) to publish initially: ${packagesToPublish
.map(p => p.name)
.join(', ')}`
);

// Conditionally run changeset:prepublish if there are packages to publish
if (packagesToPublish.length > 0) {
console.log('New packages found. Running changeset:prepublish to build packages...');
try {
runCommand('yarn', ['run', 'changeset:prepublish']); // Assumes it runs from rootDir
console.log('changeset:prepublish completed successfully.');
} catch (prepublishError) {
console.error('Failed to run changeset:prepublish:', prepublishError.message);
process.exit(1); // Exit if build fails, as publishing would also fail
}
}
}

let hasPublishErrors = false;
for (const pkg of packagesToPublish) {
console.log(`[DEBUG] Attempting to publish from list: ${JSON.stringify(pkg)}`); // Added for debugging
console.log(`Attempting to publish ${pkg.name} from ${pkg.dir} with alpha tag...`);
const packageJsonPath = path.join(pkg.dir, 'package.json');
let originalPackageJson = '';
try {
originalPackageJson = fs.readFileSync(packageJsonPath, 'utf8');
const parsedPackageJson = JSON.parse(originalPackageJson);

if (parsedPackageJson.private === true) {
console.log(`Package ${pkg.name} is private, skipping initial publish.`);
continue; // Skip to the next package
}

console.log(`Temporarily setting version of ${pkg.name} to 0.0.1 for initial publish.`);
parsedPackageJson.version = '0.0.1';
fs.writeFileSync(packageJsonPath, JSON.stringify(parsedPackageJson, null, 2));

runCommand('yarn', ['npm', 'publish', '--access', 'public', '--tag', 'alpha'], {
cwd: pkg.dir
});
// console.log(
// `DRY RUN: Would publish ${pkg.name} from ${pkg.dir} with version 0.0.1 and alpha tag.`
// );
// console.log(
// `DRY RUN: Command would be: yarn npm publish --access public --tag alpha (in ${pkg.dir})`
// );
} catch (publishError) {
// runCommand already logs error details if it's from there
console.error(`Failed to publish ${pkg.name}: ${publishError.message}`);
hasPublishErrors = true; // Mark that an error occurred but continue trying other packages
} finally {
// Restore original package.json
if (originalPackageJson) {
console.log(`Restoring original package.json for ${pkg.name}.`);
try {
fs.writeFileSync(packageJsonPath, originalPackageJson);
} catch (restoreError) {
console.error(
`CRITICAL: Failed to restore original package.json for ${pkg.name}: ${restoreError.message}`
);
// This is a more critical error, as it leaves the repo in a modified state.
// Depending on desired behavior, you might want to ensure this error is highly visible
// or even causes the entire workflow to fail more loudly.
hasPublishErrors = true; // Ensure the overall process is marked as failed.
}
}
}
}

console.log('Initial package publishing process finished.');
if (hasPublishErrors) {
console.error('One or more packages failed during initial publishing.');
process.exit(1); // Exit with error if any package failed to publish
}
2 changes: 1 addition & 1 deletion .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4

- name:
- name: Setup Environment
uses: ./.github/actions/setup

- name: Create Release Pull Request or Publish to NPM
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ jobs:
- name: Setup
uses: ./.github/actions/setup

- name: Publish Initial Versions for New Packages
continue-on-error: false
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm config set "//registry.npmjs.org/:_authToken" "$NPM_TOKEN"
node .github/scripts/publish-initial-versions.js

- name: Publish Snapshots
continue-on-error: false
env:
Expand Down
Loading