Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into jerryliu-sc-77755-k…
Browse files Browse the repository at this point in the history
…resus-hotfix
  • Loading branch information
Ethella committed May 18, 2023
2 parents 6bf4b7b + 44cb1ef commit ea52e25
Show file tree
Hide file tree
Showing 46 changed files with 494 additions and 108 deletions.
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# (Thu May 18 2023)

#### 🐛 Bug Fix

- `@magic-sdk/[email protected]`
- Add conditional for `useInstead` of `loginWithMagicLink` `createDeprecationWarning` call [#518](https://github.com/magiclabs/magic-js/pull/518) ([@Ariflo](https://github.com/Ariflo))

#### Authors: 1

- Arian Flores ([@Ariflo](https://github.com/Ariflo))

---

# (Thu May 18 2023)

#### 🚀 Enhancement

- `@magic-ext/[email protected]`
- Add @magic-ext/aptos package [#515](https://github.com/magiclabs/magic-js/pull/515) ([@octave08](https://github.com/octave08))

#### Authors: 1

- Jay Hwang ([@octave08](https://github.com/octave08))

---

# (Thu May 11 2023)

#### 🐛 Bug Fix

- `@magic-sdk/[email protected]`
- [FIX]: updates for Sardines new API spec [#511](https://github.com/magiclabs/magic-js/pull/511) ([@bengriffin1](https://github.com/bengriffin1))
- `@magic-sdk/[email protected]`
- update Webview version in README [#510](https://github.com/magiclabs/magic-js/pull/510) ([@am-hernandez](https://github.com/am-hernandez))

#### Authors: 2

- A.M. Hernandez ([@am-hernandez](https://github.com/am-hernandez))
- Ben Griffin ([@bengriffin1](https://github.com/bengriffin1))

---

# (Wed May 10 2023)

#### 🚀 Enhancement
Expand Down
4 changes: 2 additions & 2 deletions packages/@magic-ext/algorand/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magic-ext/algorand",
"version": "12.1.2",
"version": "12.1.4",
"description": "magic algorand extension",
"author": "Magic <[email protected]> (https://magic.link/)",
"license": "MIT",
Expand Down Expand Up @@ -28,6 +28,6 @@
]
},
"devDependencies": {
"@magic-sdk/commons": "^13.1.2"
"@magic-sdk/commons": "^13.1.4"
}
}
5 changes: 5 additions & 0 deletions packages/@magic-ext/aptos/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules
/coverage
/dist
/.eslintrc.js
/jest.config.ts
7 changes: 7 additions & 0 deletions packages/@magic-ext/aptos/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ['../../../.eslintrc.js'],
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
}
2 changes: 2 additions & 0 deletions packages/@magic-ext/aptos/.lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'*.{ts,tsx}':
- eslint --fix
1 change: 1 addition & 0 deletions packages/@magic-ext/aptos/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../../.prettierrc.js');
24 changes: 24 additions & 0 deletions packages/@magic-ext/aptos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# v0.2.0 (Thu May 18 2023)

#### 🚀 Enhancement

- Add @magic-ext/aptos package [#515](https://github.com/magiclabs/magic-js/pull/515) ([@octave08](https://github.com/octave08))

#### 🐛 Bug Fix

- Update years of LICENSE ([@octave08](https://github.com/octave08))
- Simplify error handling ([@octave08](https://github.com/octave08))
- Refactor signTransation with safe-call ([@octave08](https://github.com/octave08))
- Remove CHANGELOG.md ([@octave08](https://github.com/octave08))
- Update error message ([@octave08](https://github.com/octave08))
- Reset version for @magic-ext/aptos ([@octave08](https://github.com/octave08))
- Serialize transaction ([@octave08](https://github.com/octave08))
- Add signTransaction method ([@octave08](https://github.com/octave08))
- Add chainId to AptosConfig ([@octave08](https://github.com/octave08))
- clean code ([@octave08](https://github.com/octave08))
- feat: add more configs ([@octave08](https://github.com/octave08))
- Init @magic-ext/aptos package ([@octave08](https://github.com/octave08))

#### Authors: 1

- Jay Hwang ([@octave08](https://github.com/octave08))
21 changes: 21 additions & 0 deletions packages/@magic-ext/aptos/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023-present Magic Labs, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
36 changes: 36 additions & 0 deletions packages/@magic-ext/aptos/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@magic-ext/aptos",
"version": "0.2.1",
"description": "magic aptos extension",
"author": "Magic <[email protected]> (https://magic.link/)",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/magiclabs/magic-js"
},
"files": [
"dist"
],
"target": "neutral",
"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"types": "./dist/types/index.d.ts",
"jsdelivr": "./dist/extension.js",
"react-native": "./dist/react-native/index.native.js",
"exports": {
"import": "./dist/es/index.mjs",
"require": "./dist/cjs/index.js"
},
"externals": {
"include": [
"@magic-sdk/commons"
]
},
"devDependencies": {
"@magic-sdk/commons": "^13.1.4",
"aptos": "^1.8.5"
},
"peerDependencies": {
"aptos": "^1.8.5"
}
}
3 changes: 3 additions & 0 deletions packages/@magic-ext/aptos/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { AptosExtension } from './index';

export default AptosExtension;
1 change: 1 addition & 0 deletions packages/@magic-ext/aptos/src/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './index';
78 changes: 78 additions & 0 deletions packages/@magic-ext/aptos/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { Extension } from '@magic-sdk/commons';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { BCS } from 'aptos';
import { AptosConfig, ConfigType, AptosPayloadMethod } from './type';

const getDefaultConfig = (nodeUrl: string) => {
if (nodeUrl === 'https://fullnode.mainnet.aptoslabs.com') {
return {
rpcUrl: 'https://aptos-mainnet-rpc.allthatnode.com/v1',
network: 'mainnet',
chainId: 1,
};
}

if (nodeUrl === 'https://fullnode.testnet.aptoslabs.com') {
return {
rpcUrl: 'https://aptos-testnet-rpc.allthatnode.com/v1',
network: 'testnet',
chainId: 2,
};
}

if (nodeUrl === 'https://fullnode.devnet.aptoslabs.com') {
return {
rpcUrl: '',
network: 'devnet',
chainId: 54,
};
}

throw new Error('Invalid nodeUrl');
};

export class AptosExtension extends Extension.Internal<'aptos', any> {
name = 'aptos' as const;
config: ConfigType;

constructor(public aptosConfig: AptosConfig) {
super();

const defaultConfig = getDefaultConfig(aptosConfig.nodeUrl);

this.config = {
chainType: 'APTOS',
nodeUrl: aptosConfig.nodeUrl,
rpcUrl: aptosConfig.rpcUrl ?? defaultConfig.rpcUrl,
network: aptosConfig.network ?? defaultConfig.network,
chainId: aptosConfig.chainId ?? defaultConfig.chainId,
};
}

private serializeRawTranasction = (rawTranasction: any) => {
try {
const s = new BCS.Serializer();
rawTranasction.serialize(s);
return s.getBytes();
} catch (e) {
console.error(
'Invalid transaction. Please generate transaction with generateTransaction method of aptos sdk.',
e,
);
throw e;
}
};

getAccount = () => {
return this.request<string>(this.utils.createJsonRpcRequestPayload(AptosPayloadMethod.AptosGetAccount, []));
};

signTransaction = (rawTransaction: any) => {
const serialized = this.serializeRawTranasction(rawTransaction);
return this.request<Uint8Array>(
this.utils.createJsonRpcRequestPayload(AptosPayloadMethod.AptosSignTransaction, [serialized]),
);
};
}
19 changes: 19 additions & 0 deletions packages/@magic-ext/aptos/src/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export interface AptosConfig {
nodeUrl: string;
rpcUrl?: string;
network?: string;
chainId?: number;
}

export interface ConfigType {
rpcUrl: string;
nodeUrl: string;
network: string;
chainType: string;
chainId: number;
}

export enum AptosPayloadMethod {
AptosGetAccount = 'aptos_getAccount',
AptosSignTransaction = 'aptos_signTransaction',
}
4 changes: 4 additions & 0 deletions packages/@magic-ext/aptos/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../../tsconfig.settings.json",
}

4 changes: 2 additions & 2 deletions packages/@magic-ext/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magic-ext/auth",
"version": "0.2.2",
"version": "0.2.4",
"description": "Magic SDK Extension for the Auth module",
"author": "Magic <[email protected]> (https://magic.link/)",
"license": "MIT",
Expand Down Expand Up @@ -28,6 +28,6 @@
]
},
"devDependencies": {
"@magic-sdk/commons": "^13.1.2"
"@magic-sdk/commons": "^13.1.4"
}
}
4 changes: 2 additions & 2 deletions packages/@magic-ext/avalanche/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magic-ext/avalanche",
"version": "12.1.2",
"version": "12.1.4",
"description": "magic avalanche extension",
"author": "Magic <[email protected]> (https://magic.link/)",
"license": "MIT",
Expand Down Expand Up @@ -28,6 +28,6 @@
]
},
"devDependencies": {
"@magic-sdk/commons": "^13.1.2"
"@magic-sdk/commons": "^13.1.4"
}
}
4 changes: 2 additions & 2 deletions packages/@magic-ext/bitcoin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magic-ext/bitcoin",
"version": "12.1.2",
"version": "12.1.4",
"description": "magic bitcoin extension",
"author": "Magic <[email protected]> (https://magic.link/)",
"license": "MIT",
Expand All @@ -27,6 +27,6 @@
]
},
"devDependencies": {
"@magic-sdk/commons": "^13.1.2"
"@magic-sdk/commons": "^13.1.4"
}
}
4 changes: 2 additions & 2 deletions packages/@magic-ext/conflux/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magic-ext/conflux",
"version": "10.1.2",
"version": "10.1.4",
"description": "magic conflux extension",
"author": "Magic <[email protected]> (https://magic.link/)",
"license": "MIT",
Expand Down Expand Up @@ -28,6 +28,6 @@
]
},
"devDependencies": {
"@magic-sdk/commons": "^13.1.2"
"@magic-sdk/commons": "^13.1.4"
}
}
4 changes: 2 additions & 2 deletions packages/@magic-ext/cosmos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magic-ext/cosmos",
"version": "12.1.2",
"version": "12.1.4",
"description": "magic cosmos extension",
"author": "Magic <[email protected]> (https://magic.link/)",
"license": "MIT",
Expand Down Expand Up @@ -28,6 +28,6 @@
]
},
"devDependencies": {
"@magic-sdk/commons": "^13.1.2"
"@magic-sdk/commons": "^13.1.4"
}
}
4 changes: 2 additions & 2 deletions packages/@magic-ext/ed25519/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magic-ext/ed25519",
"version": "8.1.2",
"version": "8.1.4",
"description": "magic ed25519 extension",
"author": "Magic <[email protected]> (https://magic.link/)",
"license": "MIT",
Expand Down Expand Up @@ -28,6 +28,6 @@
]
},
"devDependencies": {
"@magic-sdk/commons": "^13.1.2"
"@magic-sdk/commons": "^13.1.4"
}
}
4 changes: 2 additions & 2 deletions packages/@magic-ext/flow/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magic-ext/flow",
"version": "12.1.2",
"version": "12.1.4",
"description": "magic flow extension",
"author": "Magic <[email protected]> (https://magic.link/)",
"license": "MIT",
Expand All @@ -27,7 +27,7 @@
]
},
"devDependencies": {
"@magic-sdk/commons": "^13.1.2",
"@magic-sdk/commons": "^13.1.4",
"@onflow/fcl": "0.0.41",
"@onflow/types": "0.0.3"
},
Expand Down
Loading

0 comments on commit ea52e25

Please sign in to comment.