Skip to content

Commit

Permalink
Merge branch 'main' into ignore-https-agent-browser
Browse files Browse the repository at this point in the history
  • Loading branch information
mpint committed Nov 16, 2022
2 parents 4f0c864 + c4c8e58 commit 82c5054
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 50 deletions.
178 changes: 131 additions & 47 deletions .github/workflows/nodejs.yml
Expand Up @@ -12,46 +12,89 @@ on:
jobs:
build-and-lint:
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install -g npm@7
- run: npm ci
- run: npm run build
- run: npm run lint
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Setup npm version 7
run: |
npm i -g npm@7 --registry=https://registry.npmjs.org
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-deps-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-deps-${{ matrix.node-version }}-
${{ runner.os }}-deps-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci

- run: npm run build
- run: npm run lint

unit:
runs-on: ubuntu-latest

timeout-minutes: 10

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- run: npm install -g npm@7
- run: npm ci
- run: npm run build
- run: npm test
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Setup npm version 7
run: |
npm i -g npm@7 --registry=https://registry.npmjs.org
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-deps-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-deps-${{ matrix.node-version }}-
${{ runner.os }}-deps-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci

- run: npm run build
- run: npm test

integration:
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
Expand All @@ -66,23 +109,44 @@ jobs:
--health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- run: npm install -g npm@7
- run: npm ci
- run: npm run build
- run: npm run test:integration
env:
HOST: localhost
PORT: ${{ job.services.rippled.ports['6006'] }}
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Setup npm version 7
run: |
npm i -g npm@7 --registry=https://registry.npmjs.org
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-deps-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-deps-${{ matrix.node-version }}-
${{ runner.os }}-deps-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci

- run: npm run build
- run: npm run test:integration
env:
HOST: localhost
PORT: ${{ job.services.rippled.ports['6006'] }}

browser:
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
Expand All @@ -97,14 +161,34 @@ jobs:
--health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- run: npm install -g npm@7
- run: npm ci
- run: npm run build
- run: npm run test:browser
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Setup npm version 7
run: |
npm i -g npm@7 --registry=https://registry.npmjs.org
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-deps-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-deps-${{ matrix.node-version }}-
${{ runner.os }}-deps-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci

- run: npm run build
- run: npm run test:browser
4 changes: 4 additions & 0 deletions packages/xrpl/HISTORY.md
Expand Up @@ -4,6 +4,10 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
## Unreleased
### Added
* Optional custom amount field to `fundWallet`.

### Changed
* Add support for Transaction objects in `verifyTransaction`

## 2.5.0 (2022-10-13)
### Added
* Support for ExpandedSignerList amendment that expands the maximum signer list to 32 entries.
Expand Down
7 changes: 5 additions & 2 deletions packages/xrpl/src/Wallet/index.ts
Expand Up @@ -375,8 +375,11 @@ class Wallet {
* @param signedTransaction - A signed transaction (hex string of signTransaction result) to be verified offline.
* @returns Returns true if a signedTransaction is valid.
*/
public verifyTransaction(signedTransaction: string): boolean {
const tx = decode(signedTransaction)
public verifyTransaction(signedTransaction: Transaction | string): boolean {
const tx =
typeof signedTransaction === 'string'
? decode(signedTransaction)
: signedTransaction
const messageHex: string = encodeForSigning(tx)
const signature = tx.TxnSignature
return verify(messageHex, signature, this.publicKey)
Expand Down
12 changes: 11 additions & 1 deletion packages/xrpl/test/wallet/index.ts
@@ -1,5 +1,5 @@
import { assert } from 'chai'
import { decode } from 'ripple-binary-codec/dist'
import { decode } from 'ripple-binary-codec'
import { NFTokenMint, Payment, Transaction } from 'xrpl-local'
import ECDSA from 'xrpl-local/ECDSA'
import Wallet from 'xrpl-local/Wallet'
Expand Down Expand Up @@ -949,6 +949,16 @@ describe('Wallet', function () {

assert.equal(isVerified, false)
})

it('returns true when verifying a deserialized Transaction object', function () {
const wallet = new Wallet(publicKey, privateKey)
const decodedTransaction = decode(
prepared.signedTransaction,
) as unknown as Transaction
const isVerified: boolean = wallet.verifyTransaction(decodedTransaction)

assert.equal(isVerified, true)
})
})

describe('getXAddress', function () {
Expand Down

0 comments on commit 82c5054

Please sign in to comment.