Skip to content

Commit

Permalink
Updated readme, added workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Hergen Dillema committed Jan 7, 2023
1 parent 8fb4e08 commit c877122
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 11 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Code Quality

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

defaults:
run:
working-directory: .

jobs:

unit-test:
runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ${{ env.composer_cache_dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Unit tests
run: vendor/bin/phpunit

code-style-check:
runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ${{ env.composer_cache_dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Code Style checks
run: vendor/bin/ecs check --no-progress-bar
24 changes: 14 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,22 @@ The `networkId` is `null` by default, and when no nonce is set, it will default

Signers must be present in a signed command, but using the `getSignedCommand` will take care of that for you.

First, let's create a payload and metadata to construct our command:
First, let's create metadata to construct our command:

```php
$metadata = new Meta(
creationTime: Carbon::now(),
ttl: 0,
gasLimit: 0,
chainId: '',
gasPrice: 0,
sender: ''
);

$metadata = Meta::create();
```
The `create()` method takes an optional array of options, options with their default values are:
```php
creationTime: Carbon::now(),
ttl: 7200,
gasLimit: 10000,
chainId: '0',
gasPrice: 1e-8,
sender: ''
```
Then create a payload:
```php
$executePayload = new Payload(
payloadType: PayloadType::EXECUTE,
executePayload: new ExecutePayload(
Expand Down
2 changes: 1 addition & 1 deletion src/Pact/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function toArray(): array
];
}

public static function create(array $options = []): self
public static function create(?array $options = []): self
{
return new self(
creationTime: (isset($options['creationTime'])) ? Carbon::createFromTimestamp((int) $options['creationTime']) : Carbon::now(),
Expand Down

0 comments on commit c877122

Please sign in to comment.