Skip to content
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

feat: walletconnect-legacy #137

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- [@nstudio/nativescript-qr](packages/nativescript-qr/README.md)
- [@nstudio/nativescript-tracking-transparency](packages/nativescript-tracking-transparency/README.md)
- [@nstudio/nativescript-walletconnect](packages/nativescript-walletconnect/README.md)
- [@nstudio/nativescript-walletconnect-legacy](packages/nativescript-walletconnect-legacy/README.md)

# How to use?

Expand Down
3 changes: 2 additions & 1 deletion apps/demo-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"main": "./src/main.ts",
"dependencies": {
"@nativescript/core": "file:../../node_modules/@nativescript/core",
"@nstudio/nativescript-appcues": "file:../../dist/packages/nativescript-appcues",
"@nstudio/nativescript-walletconnect-legacy": "file:../../dist/packages/nativescript-walletconnect-legacy",
"@nstudio/nativescript-airship": "file:../../dist/packages/nativescript-airship",
"@nstudio/nativescript-airship-adm": "file:../../dist/packages/nativescript-airship-adm",
"@nstudio/nativescript-airship-fcm": "file:../../dist/packages/nativescript-airship-fcm",
"@nstudio/nativescript-airship-hms": "file:../../dist/packages/nativescript-airship-hms",
"@nstudio/nativescript-appcues": "file:../../dist/packages/nativescript-appcues",
"@nstudio/nativescript-aptabase": "file:../../dist/packages/nativescript-aptabase",
"@nstudio/nativescript-barcodescanner": "file:../../dist/packages/nativescript-barcodescanner",
"@nstudio/nativescript-blur": "file:../../dist/packages/nativescript-blur",
Expand Down
3 changes: 2 additions & 1 deletion apps/demo-angular/src/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const routes: Routes = [
{ path: 'nativescript-plaid', loadChildren: () => import('./plugin-demos/nativescript-plaid.module').then(m => m.NativescriptPlaidModule) },
{ path: 'nativescript-qr', loadChildren: () => import('./plugin-demos/nativescript-qr.module').then(m => m.NativescriptQrModule) },
{ path: 'nativescript-tracking-transparency', loadChildren: () => import('./plugin-demos/nativescript-tracking-transparency.module').then(m => m.NativescriptTrackingTransparencyModule) },
{ path: 'nativescript-walletconnect', loadChildren: () => import('./plugin-demos/nativescript-walletconnect.module').then(m => m.NativescriptWalletconnectModule) }
{ path: 'nativescript-walletconnect', loadChildren: () => import('./plugin-demos/nativescript-walletconnect.module').then(m => m.NativescriptWalletconnectModule) },
{ path: 'nativescript-walletconnect-legacy', loadChildren: () => import('./plugin-demos/nativescript-walletconnect-legacy.module').then(m => m.NativescriptWalletconnectLegacyModule) }
];

@NgModule({
Expand Down
3 changes: 3 additions & 0 deletions apps/demo-angular/src/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export class HomeComponent {
},
{
name: 'nativescript-walletconnect'
},
{
name: 'nativescript-walletconnect-legacy'
}
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ActionBar title="nativescript-walletconnect-legacy" class="action-bar"> </ActionBar>
<StackLayout class="p-20">
<ScrollView class="h-full">
<StackLayout>
<Button text="Test nativescript-walletconnect-legacy" (tap)="demoShared.testIt()" class="btn btn-primary"></Button>
</StackLayout>
</ScrollView>
</StackLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedNativescriptWalletconnectLegacy } from '@demo/shared';
import {} from '@nstudio/nativescript-walletconnect-legacy';

@Component({
selector: 'demo-nativescript-walletconnect-legacy',
templateUrl: 'nativescript-walletconnect-legacy.component.html',
})
export class NativescriptWalletconnectLegacyComponent {
demoShared: DemoSharedNativescriptWalletconnectLegacy;

constructor(private _ngZone: NgZone) {}

ngOnInit() {
this.demoShared = new DemoSharedNativescriptWalletconnectLegacy();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';
import { NativescriptWalletconnectLegacyComponent } from './nativescript-walletconnect-legacy.component';

@NgModule({
imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild([{ path: '', component: NativescriptWalletconnectLegacyComponent }])],
declarations: [NativescriptWalletconnectLegacyComponent],
schemas: [NO_ERRORS_SCHEMA],
})
export class NativescriptWalletconnectLegacyModule {}
3 changes: 2 additions & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"description": "NativeScript Application",
"dependencies": {
"@nativescript/core": "file:../../node_modules/@nativescript/core",
"@nstudio/nativescript-appcues": "file:../../packages/nativescript-appcues",
"@nstudio/nativescript-walletconnect-legacy": "file:../../packages/nativescript-walletconnect-legacy",
"@nstudio/nativescript-airship": "file:../../packages/nativescript-airship",
"@nstudio/nativescript-airship-adm": "file:../../packages/nativescript-airship-adm",
"@nstudio/nativescript-airship-fcm": "file:../../packages/nativescript-airship-fcm",
"@nstudio/nativescript-airship-hms": "file:../../packages/nativescript-airship-hms",
"@nstudio/nativescript-appcues": "file:../../packages/nativescript-appcues",
"@nstudio/nativescript-aptabase": "file:../../packages/nativescript-aptabase",
"@nstudio/nativescript-barcodescanner": "file:../../packages/nativescript-barcodescanner",
"@nstudio/nativescript-blur": "file:../../packages/nativescript-blur",
Expand Down
1 change: 1 addition & 0 deletions apps/demo/src/main-page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<Button text="nativescript-qr" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
<Button text="nativescript-tracking-transparency" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
<Button text="nativescript-walletconnect" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
<Button text="nativescript-walletconnect-legacy" tap="{{ viewDemo }}" class="btn btn-primary view-demo"/>
</StackLayout>
</ScrollView>
</StackLayout>
Expand Down
57 changes: 57 additions & 0 deletions apps/demo/src/plugin-demos/nativescript-walletconnect-legacy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Observable, EventData, Page } from '@nativescript/core';
import { DemoSharedNativescriptWalletconnectLegacy } from '@demo/shared';
import { WalletConnect } from '@nstudio/nativescript-walletconnect-legacy';

export function navigatingTo(args: EventData) {
const page = <Page>args.object;
page.bindingContext = new DemoModel();
}

export class DemoModel extends DemoSharedNativescriptWalletconnectLegacy {
wc: WalletConnect;
uri = '';
connect() {
if (this.wc) {
this.wc.killSession();
this.wc = null;
return;
}
//const uri = decodeURIComponent(this.uri);

this.wc = new WalletConnect({
uri: this.uri,
clientMeta: {
description: 'WalletConnect Developer App',
url: 'https://walletconnect.org',
icons: ['https://walletconnect.org/walletconnect-logo.png'],
name: 'WalletConnect',
},
});

this.wc.on('session_request', (error, payload) => {
this.wc.approveSession({
accounts: ['0xCF4140193531B8b2d6864cA7486Ff2e18da5cA95'],
chainId: 1,
});
});

this.wc.on('connect', (error, payload) => {});

this.wc
.createSession()
.then((value) => {
console.log('hello', value);
})
.catch((error) => {
console.log(error);
});
}

killSession() {
this.wc?.killSession();
}

disconnect() {
this.wc?.disconnect();
}
}
20 changes: 20 additions & 0 deletions apps/demo/src/plugin-demos/nativescript-walletconnect-legacy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
<Page.actionBar>
<ActionBar title="nativescript-walletconnect-legacy" icon="" class="action-bar">
</ActionBar>
</Page.actionBar>
<StackLayout class="p-20">
<ScrollView class="h-full">
<StackLayout>
<TextView text="{{ uri }}"/>

<Button text="Connect" tap="{{ connect }}" class="btn btn-primary"/>

<Button text="KillSession" tap="{{ killSession }}" class="btn btn-primary"/>

<Button text="Disconnect" tap="{{ disconnect }}" class="btn btn-primary"/>

</StackLayout>
</ScrollView>
</StackLayout>
</Page>
18 changes: 18 additions & 0 deletions packages/nativescript-walletconnect-legacy/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "node_modules/**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
13 changes: 13 additions & 0 deletions packages/nativescript-walletconnect-legacy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @nstudio/nativescript-walletconnect-legacy

```javascript
npm install @nstudio/nativescript-walletconnect-legacy
```

## Usage

// TODO

## License

Apache License Version 2.0
3 changes: 3 additions & 0 deletions packages/nativescript-walletconnect-legacy/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Observable } from '@nativescript/core';

export class NativescriptWalletconnectLegacyCommon extends Observable {}
Loading